Thursday 3 October 2013

Adding 'n' numbers using C

#include<stdio.h>
main()
{
int n,i,sum=0,value;
printf("\n(There is) none worthy of worship except Allah(Subhanahu wa ta'ala).Muhammad(Sallallahu alayhi wasallam) is Messenger of ALLAH(Subhanahu wa ta'ala).\n");
printf("Enter the number of integers you want to add\n");
scanf("%d",&n);
printf("Enter %d Integers\n",n);
for(i=1;i<=n;i++)
{
scanf("%d",&value);
sum=sum+value;
}
printf("\n Sum of given %d integers is %d \n",n,sum);
}

No comments:

Post a Comment