+ 4

What's wrong with this code?

#include <stdio.h> int main() { int a=5; int b=1,c; printf("Enter no:\n"); scanf("%d",&a); for(c=a;a>=1:a--) { b=b*a; } printf("Factorial of given no %d is %d\n",c,b); return 0; }

25th May 2020, 11:17 AM
Coding San
Coding San - avatar
3 ответов
+ 4
There is an error in syntaxe of for Change : to ; befor a-- in for loop
25th May 2020, 11:22 AM
Youssef Radid
Youssef Radid - avatar
+ 3
Wrong syntax of *for* loop(as mentioned by Youssef Radid ) Here is the fix👇 https://code.sololearn.com/cxsKFs6JZzqj/?ref=app
25th May 2020, 11:24 AM
Arsenic
Arsenic - avatar
+ 1
Hey there, you just did not put semi-colon after a>=1 this. Your Code After All Error Fixing: - #include <stdio.h> int main() { int a=5; int b=1,c; printf("Enter no:\n"); scanf("%d",&a); for(c=a;a>=1;a--) { b=b*a; } printf("Factorial of given no %d is %d\n",c,b); return 0; }
25th May 2020, 3:47 PM
Ankit Saini
Ankit Saini - avatar