questions on computer
Answers
Answer:
I am writing the code in basic C language
//C code to calculate total and AVG marks of 'n' students and display the result
#include<stdio.h>
#define N 100
int main()
{
int n, total=0, avg, a[N], i;
/*Here n=no. of students, total=To store total value, avg=To store AVG value, The array a[N} is to store the input marks of the students*/
Printf("Enter no. of students");
scanf("%d",&n);
Printf("Enter the marks:");
for(i=0;i<n;i++) {
scanf("%d\n",&a[i]);
}
//Now calculate the total marks
for(i=0;i<n;i++) {
total= total+a[i];
}
//Now calculate the AVG
avg = total/n;
//Displaying the result
printf("The total marks of the students are: %d", total);
printf("The AVG marks is: %d", avg);
return 0;
}
Hope this helps,
Thank you
Explanation:
Answer:
int n, total=0, avg, a[N], i;
/*Here n=no. of students, total=To store total value, avg=To store AVG value, The array a[N} is to store the input marks of the students*/
Printf("Enter no. of students");
scanf("%d",&n);
Printf("Enter the marks:");
for(i=0;i<n;i++) {
scanf("%d\n",&a[i]);
}
//Now calculate the total marks
for(i=0;i<n;i++) {
total= total+a[i];
}
//Now calculate the AVG
avg = total/n;
//Displaying the result
printf("The total marks of the students are: %d", total);
printf("The AVG marks is: %d", avg);
return 0;
}
Explanation: