Learn C ProgrammingLearn ProgrammingLoop Control StructuresPrograms On Loop Control Structures For LoopResources

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

By September 18, 2012 February 5th, 2018 2 Comments
#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);
}


2 Comments

Leave a Reply

DEMO01