0

Check for fisher number!

What is wrong with my code? (I have written in C!) #include <stdio.h> #include <stdlib.h> int main() { int i,mult,n; printf("Enter the number to check for fisher: "); scanf("%d",&n); i=1; while(n>=i) { if(n%i==0) mult*=i; i++; } if((n*n*n)==mult) { printf("Fisher\n"); } else printf("Not fisher\n"); return 0; }

3rd Aug 2018, 4:56 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
8 Antworten
+ 2
You didn't initialize mult. You will get garbage cause of that. Also add curly braces to the last else statement.
3rd Aug 2018, 5:15 AM
Akib
Akib - avatar
+ 1
What error msg are you getting?
3rd Aug 2018, 5:29 AM
Akib
Akib - avatar
+ 1
it worked....by mistake i initialised mult to 0 instead of 1
3rd Aug 2018, 5:35 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
+ 1
If you get the answers mark it. Its easier for others to see if questions are answered or not. And welcome😁
3rd Aug 2018, 5:37 AM
Akib
Akib - avatar
0
I initialized mult=1 and added curly braces to the last else....still not working
3rd Aug 2018, 5:26 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
0
Thanks :D
3rd Aug 2018, 5:35 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
0
what should I mark?
3rd Aug 2018, 5:38 AM
Abhishek Tiwari
Abhishek Tiwari - avatar
0
Marked it...Thanks again :D
3rd Aug 2018, 5:40 AM
Abhishek Tiwari
Abhishek Tiwari - avatar