Wednesday 21 December 2011


TO DISPLAY FACTORIAL OF ODD NUMBERS FROM 1 TO 10 AND THEIR SUM




#include<stdio.h>
Void main()
{
Int i=1;
Float fact=1.0,sum=0.0;
Printf(“odd numbers\t\tfactorial”);
For(;i<=10;++i,fact*=i)
If((i%2)==1)
{
Printf(“ %d \t\t %g\n”,i,fact);
Sum+=fact;
}
Printf(“sum of above factorials is %g”,sum);
Getch();
}


No comments:

Post a Comment