write a c program by using array for Store 10 students computer science marg and find the highest mark
Answers
Answered by
3
Explanation:
#include <stdio.h>
int main() {
int i, n;
float arr[100];
printf("Enter the number of elements (1 to 100): ");
scanf("%d", &n);
for (i = 0; i < n; ++i) {
printf("Enter number%d: ", i + 1);
scanf("%f", &arr[i]);
}
// storing the largest number to arr[0]
for (i = 1; i < n; ++i) {
if (arr[0] < arr[i])
arr[0] = arr[i];
}
printf("Largest element = %.2f", arr[0]);
return 0;
}
Output
Enter the number of elements (1 to 100): 5
Enter number1: 34.5
Enter number2: 2.4
Enter number3: -35.5
Enter number4: 38.7
Enter number5: 24.5
Largest element = 38.70
Similar questions
Math,
2 months ago
Computer Science,
2 months ago
Math,
2 months ago
English,
5 months ago
Social Sciences,
5 months ago
Social Sciences,
10 months ago
Science,
10 months ago
India Languages,
10 months ago