johnny.de
Cadet 4th Year
- Registriert
- Aug. 2006
- Beiträge
- 127
//Fakultät
#include <iostream>
using namespace std;
void main()
{
int fakul=1, zahl, hilf;
cout<<"Geben Sie eine Zahl ein, "<<endl;
cout<<"von der die Fakultaet berechnet werden soll."<<endl;
cin>>zahl;
cout<<endl;
hilf=zahl;
while(hilf > 0)
{
fakul = fakul * hilf--;
cout<<hilf;
}
cout<<zahl<<"!= "<<fakul<<endl;
}
bei der Ausführung werden 4 3 2 1 0 und 5!=120 ausgegeben.
das kann ich ja nachvollziehen und 5! sind ja auch 120, nur wenn ich 4*3*2*1*0 rechne kommt da ja 0 raus und nicht 120.
wieso ist fakul dann 120 ????
#include <iostream>
using namespace std;
void main()
{
int fakul=1, zahl, hilf;
cout<<"Geben Sie eine Zahl ein, "<<endl;
cout<<"von der die Fakultaet berechnet werden soll."<<endl;
cin>>zahl;
cout<<endl;
hilf=zahl;
while(hilf > 0)
{
fakul = fakul * hilf--;
cout<<hilf;
}
cout<<zahl<<"!= "<<fakul<<endl;
}
bei der Ausführung werden 4 3 2 1 0 und 5!=120 ausgegeben.
das kann ich ja nachvollziehen und 5! sind ja auch 120, nur wenn ich 4*3*2*1*0 rechne kommt da ja 0 raus und nicht 120.
wieso ist fakul dann 120 ????