KodeGod.com

033. Write a program to print sum of given first n numbers in C language

#include<stdio.h> 
#include<conio.h>  
main()
{
 int n,newn,i,sum=0;
 clrscr();
 printf("Enter number : ");
 scanf("%d",&n);
 printf("Numbers entered....\n");
 for(i=1;i<=n;i++)
 {
	scanf("%d",&newn);
	sum=sum+newn;
 }
 printf("Sum of given n digits is... %d",sum);
}