Below is my program.
#include<stdio.h>
int main(){
int i,n,m;
int sum=0;
scanf("%d",&n);
for(i=0;i<n;i++){
printf("Enter the %d mark:\n",i+1);
scanf("%d\n",&m); //here I used \n
sum=sum+m;
}
printf("%d\n",sum);
printf("%.2lf",(double)sum/n);
return 0;
}
The output I got is like
3
Enter the 1 mark:
3
4
Enter the 2 mark:
2
Enter the 3 mark:
5
9
3.00
what is the effect of \n in the scanf for this output?