Wednesday, April 9, 2014

Factorial Calculator which gives output for every value of variable in loop

SAMPLE OUTPUT
1!=1
2!=2
3!=6
4!=24

INPUT CODE


#include<stdio.h>
#include<math.h>
void line()
{
int i;
    printf("\n");
for(i=1;i<=35;i++)
    printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan-ud-Din-Shafiq\n\nReg. No .DDP-SP14-BSE-005");
printf("\n");
}
int main()
{
line();
header();
line();
int a, b, r = 1;
printf("\nEnter Factorial Number: ");
scanf("%d", &b);
{
for(a=1; a<=b; a++)
   {
r=r*a;
printf("%d! = %d \n",a,r);


   }
}
return 0;
}

No comments:

Post a Comment