Why do arrays as print extra number when given new line in c?
#include<stdio.h>
int main()
{
int marks[4];
int b;
for(b=0;b<4;b++)
{
printf("enter a no for a %d student:\n",b);
scanf("%d\n",&marks[b]);
}
return 0;
}
Why do compiler ask two number when I write '\n'
in scanf("%d\n",&marks[b]);
and not while i remove new line('\n'
) form the code