Monday 6 August 2012

Loop control structure007


Write a program to print a factorial table. 

#include <stdio.h>
#include <conio.h>


void main ( )
{
long          num = 1, fact = 1;
clrscr ( );


printf ("\n\t\t   FACTORIAL TABLE\n\n");
printf ("\n\t      NUMBER \t\t FACTORIAL");
printf ("\n\t ==================================");


while ( num <= 10 )
{
fact = fact * num;
printf ("\n\t\t %ld \t\t %ld",num, fact);
num ++;
}
printf ("\n\t ===================================");
getch ( );
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...