// Program of summation of natural number
#include
#include
void main()
{
clrscr();
int num,n,sum=0;
printf("Enter the number of natural number: ");
scanf("%d", &n);
for(num=1;num<=n;num++)
sum+=num;
printf("sum of %d natural number is=%5d\n",n,sum);
getch();
}
Algorithm
· Start
· Declare num, n, sum=0 as integer
· Write(“the number of natural number”)
· Read(“the number of natural number”)
· for(num=1;num<=n;num++)
· sum+=num
· Read("sum of natural number”)
· Stop
c programming example codes
ReplyDeletec code Define function to multiply two int