User Input for the Array in C Programming
Source code for this Tutorial
#include <stdio.h>
#include <stdlib.h>
int main()
{
int size,sum =0,avg = 0;
printf("Enter how many subjects marks you want to store!\n");
scanf("%d",&size);
int marks[size];
int counter;
for(counter = 0; counter < size; counter++ ){
printf("Enter the mark for the subject %d\n",counter+1);
scanf("%d",&marks[counter]);
}
for(counter = 0; counter < size; counter++ ){
sum = sum+marks[counter];
printf("the mark for the subject %d is %d\n",counter+1,marks[counter]);
}
avg = sum / size;
printf("the sum is %d and avg is %d",sum,avg);
return 0;
}