+ 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; }
3 Respostas
+ 4
There is an error in syntaxe of for
Change : to ; befor a-- in for loop
+ 3
Wrong syntax of *for* loop(as mentioned by Youssef Radid )
Here is the fix👇
https://code.sololearn.com/cxsKFs6JZzqj/?ref=app
+ 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;
}