OOPS
OOPS
Consider an application that allows the user to enter 5 integer values, which
includes both positive and negative numbers. The application will display the
counts the number of positive numbers and negative numbers in the application.
Use C Programming.
CODE:
#include<stdio.h>
void main()
int i, arr[100],pn=0,nn=0;
printf("Enter 5 numbers:");
for(i=0;i<5;i++)
scanf("%d",&arr[i]);
if (arr[i]>=0)
pn++;
else
nn++;
printf("\nPositive numbers:%d",pn);
printf("\nNegative numbers:%d",nn);
OUTPUT:
2. Imagine you are tasked with organizing a programming competition where
participants need to create a C program. The challenge involves creating two
arrays, each with a minimum of 4 elements. The first array
should remain unchanged, while the second array needs to be reversed.
Participants must then merge these two arrays, sort the resulting array, and
finally, print the sorted array.
Implement the solution by passing the arrays to appropriate functions.
CODE:
#include <stdio.h>
#include <stdlib.h>
mergedArray[i] = arr1[i];
mergedArray[size1 + i] = arr2[i];
mergedArray[j + 1] = temp;
}
printf("\n");
free(mergedArray);
int main() {
scanf("%d", &size1);
int arr1[size1];
scanf("%d", &arr1[i]);
scanf("%d", &size2);
int arr2[size2];
scanf("%d", &arr2[i]);
printf("\n");
return 0;
}
OUTPUT:
3. Develop a C program for a sports analytics application. The application stores the
performance scores of athletes in an array. You need to write a function “Score”
that takes as input an array of integers representing the athletes' scores and the
size of the array. The function “Score” should return a pointer to the
maximum score in the array.
CODE:
#include <stdio.h>
if (size <= 0) {
return NULL;
maxScorePtr = &scores[i];
return maxScorePtr;
int main() {
if (maxScorePtr != NULL) {
printf("The maximum score is: %d\n", *maxScorePtr);
} else {
return 0;
OUTPUT:
CODE:
#include<stdio.h>
int temp=0;
temp=*a;
*a=*b;
*b=temp;
void main()
int i,j;
scanf("%d%d",&i,&j);
swap(&i,&j);
printf("A:%d\nB:%d",i,j);
}
OUTPUT:
CODE:
#include <stdio.h>
if (size == 0 || size == 1) {
return size;
*(++current) = '\0';
int main() {
scanf("%d", &size);
scanf("%d", &arr[i]);
printf("\n");
return 0;
OUTPUT: