0
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();

int k=0;

int x;
cout<<"input the no whose no of zeroes is to be calulated at the end in its factorial";
cin>>x;
for(int i=1;i<=x;i++)
{

while(i%5==0)
{
k++;
}
}
cout<<k;
getch();
}

hey in the above code it does not give compilation error but after i input the value of x after that it did nothing ,it just got stuck there and i have to break out of it ...means first cout get printed then i enter input x after that it dont show the value of k...in above program i am calculating the no of zeros at the end of factorial by calculating the total no of 5 in the factorial product..for example in factorial 10 there are two zeros because there are two 5 like this 5*2,9,8,7,6,5,4,3,2,1......tell me what i am doing wrong

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by warbird43
0

hey how it is gettinghanged my loop is finite one...what to do then..and why it is getting hanged

0

#include <iostream>

using namespace std;

int main()
{
int i=0;
int s=1;
int N;
int factorial=1;
int sum=1;

cout << "Please Enter a number";
cin >> N;

while(N>2)
{
factorial = N * (N-1);
sum*=factorial;
N-=2;

}

cout<<sum<<endl;


return 0;
}

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.