Calculating Factorial using c language

//WAP to calculate factorial of a number
#include<stdio.h>
void main()
{
int n,s=1,i=1;
printf("Enter a number to calculate upto");
scanf("%d",&n);
while(i<=n)
{
s=s*i;
i++;
}
printf("Factorial of %d is %d",n,s);
}


Calculating Summation using c language


#include<stdio.h>
void main()
{
int n,i,s=0;
printf("calculate summation upto");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s = s+i;
}
printf("your result is%d",s);
}



0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.