This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Wednesday 5 June 2013

Program to find the sum of the first N natural numbers using FOR loop



#include<stdio.h>
void main()
{
int i, n, sum=0;
clrscr();
printf("Enter the value of n:");
scanf("%d", &n);
for(i=1; i<=n; i++)
sum=sum+i;
printf("Sum of first %d natural numbers = %d", n, sum);
getch();
}

1 comment: