0
What's wrong in the below code?
#include<stdio.h> #include<math.h> void main() { int n, t, i; printf("Enter the value of n: "); scanf("%d ", &n); for(i=1;i<=10;i++) { t=n*i; printf("Table is: %d",t); } }
4 Réponses
+ 1
You don't need math.h and it will output "Table is:" for every number which is probably not what you want. Other than that, I don't see any errors. Note that you have to enter all input as soon as you run the program, with one line per input:
77
8
45
3
... etc.
+ 1
I got it, the blank space after %d was causing the error [scanf("%d ", &n);], Anyway thanks for the help.
0
okay, so I modified the code but still I can not get any output
#include<stdio.h>
void main()
{
int n, t, i;
printf("Enter the value of n: ");
scanf("%d ", &n);
printf("The table is: ");
for(i=1;i<=10;i++)
{ t=n*i;
printf("%d",t);
}
}