Monday 6 August 2012

Loop control structure006


Write a program to find the factorial value of an input number.

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


void main ( )
{
        int          no, co = 1, fact = 1;
        clrscr ( );
                   
        printf ("\n\t Enter the number.......:"); scanf ("%d",&no);
               
        while ( co <= no )
        {                                                     
                       fact = fact * co;
                       co ++;
        }
        printf ("\n\t FACTORIAL = %d", fact);
        getch ( );
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...