I have written this code to calculate the average score of three students but it is calculating it to be zero.which is wrong.plz chk the code
#include <stdio.h>
#include <stdlib.h>
main()
{
int score[3],sum;
float avg;
printf("Enter First score\n",score[0]);
scanf("%d",&score[0]);
printf("Enter Second score\n",score[1]);
scanf("%d",&score[1]);
printf("Enter Third score\n",score[2]);
scanf("%d",&score[2]);
sum=score[0]+score[1]+score[2];
avg=sum/3;
printf("Sum=%d\n Average=%d\n",sum,avg);
system("PAUSE");
return 0;
}
Thanks in advance
#include <stdio.h>
#include <stdlib.h>
main()
{
int score[3],sum;
float avg;
printf("Enter First score\n",score[0]);
scanf("%d",&score[0]);
printf("Enter Second score\n",score[1]);
scanf("%d",&score[1]);
printf("Enter Third score\n",score[2]);
scanf("%d",&score[2]);
sum=score[0]+score[1]+score[2];
avg=sum/3;
printf("Sum=%d\n Average=%d\n",sum,avg);
system("PAUSE");
return 0;
}
Thanks in advance