Home Forums C Programming ‘while’ statement ?? Re: Re: ‘while’ statement ??

#3490
GWILouisaxwzkla
Participant

could do:


/****************************************************************
* File Name : c:programstempCG.cpp
* Date : December,7,2008
* Comments : new project
* Compiler/Assembler :
* Modifications :
*
*
*
*
*
* Program Shell Generated At: 2:47:31 p.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


#include
//#include
//#include
//#include
//#include
//#include

//using namespace std;

//main function ******************************

int main ( )
{

int number;
int factorial = 1;
int i = 1;

printf ( "Enter a positive integer : " );
scanf ( "%i" , & number );



while ( i <= number )
{
factorial = i * factorial;
i ++;
}

printf ( "the factorial is %i " , factorial );

return 0 ;
}