0
The code is written to find the factorial of a number and number of terminating zeros .
like if we gave 5 5! = 120 and it should it it has 1 terminating zero but my codes isn't running https://code.sololearn.com/cE79854s6ai4/?ref=app
2 ответов
+ 2
Try this:
#include <iostream>
using namespace std;
int cheths(int fact)
{
int r=0,count=0;
while(fact>0)
{
r= fact%10;
if(r==0){
count=count+1;
}
fact=fact/10;
}
return count;
}
int main()
{
int a ,fact=1;
cout <<"enter the number\n";
cin>>a;
for(int i=a;i>0;i--)
fact=fact*i;
cout<<a<<" ! = "<< fact<<endl;
cout << cheths(fact);
return 0;
}
0
tysm