Practice Problems _1Darray
Practice Problems _1Darray
2. Write a C program to take student marks for 3 subjects using an array and
find their result.
Sample Input :
Enter marks for subject-0: 56
Enter marks for subject-1: 75
Enter marks for subject-2: 80
Sample Output:
total=216
percentage=72
grade=B
Sample output:
both array are same
5. Write a C program to find mean and standard deviation of a set of numbers.
mean= (x1+x2+x3+...xn)/n
standard deviation=
where x1,x2…xn = are data items/ array elements
n=size of array
x̄ = Mean
σ = Standard Deviation
Sample Input:
Enter the no of elements : 6
Enter the values of elements : 2 6 5 3 2 3
Sample Output:
Mean of the given values : 3.5
standard deviation : 1.643
6. A shop stores n different types of items. The user must take input for the
number of items sold in the month and corresponding unit price.find the
monthly sale of the shop using array in C.
Sample Input :
Enter the number of items sold in the month
15 23 65 85 90
Enter the cost of per unit
5.5 10.2 12.5 5.8 8.50
Sample Output:
Monthly sale of the shop =2387.6
Sample Output:
10-2
12-2
15-3
23-1
86-1
96-1
8. Write a C program to display the elements of an array in reverse order.
Sample Input :
Enter the elements of first array
10 1 56 12 65
Sample Output:
reverse order of array elements:
65 12 56 1 10
9. Write a C program to read two 1D arrays from the user and merge them into
another 1D array.
Sample Input :
Enter the elements of array1
65 2 32 15 65
Enter the elements of array2
23 25 40 4 98
Sample output:
The array of elements are:
65 2 32 15 65 23 25 40 4 98
10. Write a C program to remove the duplicate elements from the array.
Sample Input :
Enter the value of array elements
10 12 15 10 23 12 15 15 86 96
Sample Output:
The elements of array : 10 12 15 23 86 96