Saturday, December 16, 2006

FACTORIAL


# include <-------------------------header file

# include <-------------------------header file

void main()<--------very important function this is just like main gate of any program

{<-----------------------------------intial bracket for main function

int n,fac,i=2;<---------------------------------i am taking three variables n,fac and i as integers

clrscr();<---------------this is used to clear screen .............use it or not all depends on u.

cout<<"Enter any number";<------------u can understand it in 'c' we will use printf("enter any number");


cin>>"n";<-----------------taking a value of n in c we use scanf("%d",&n);

fac=n;

while(n>0) {

i=i*n;

n--;

}

cout<<"n factorial of "<

getch();

}


No comments: