C program to find the sum of 'N' natural numbers

/* Write a C program to find the sum of 'N' natural numbers*/ #include <stdio.h> #include <conio.h> void main() {...


/* Write a C program to find the sum of 'N' natural numbers*/

#include <stdio.h>
#include <conio.h>

void main()
{
    int i, N, sum = 0;

clrscr();

  printf("Enter an integer number\n");
scanf ("%d", &N);

    for (i=1; i <= N; i++)
{
      sum = sum + i;
}

printf ("Sum of first %d natural numbers = %d\n", N, sum);
}

/*----------------------------------------
Output
RUN1

Enter an integer number
10
Sum of first 10 natural numbers = 55


RUN2

Enter an integer number
50
Sum of first 50 natural numbers = 1275
------------------------------------------*/

Related

C TUTORIAL 5830098235390721363

Post a Comment

emo-but-icon

Search Here

Popular query

Follow Us

Ads By Google

Get free Update

Enter your email address:

E-mail verification is must for complete subscription

Delivered by FeedBurner

Circle AFS on Google Plus!

Follow AFS Google+ page
 

Side Ads

DMCA protected
Information, images and the content on this blog is Copyright ©AFS2011-2018. Please do not copy Any content for commercial purpose else we have to take a legal action. Thanks !!

Total Pageviews

Recent

free counters
 

Connect Us

Speech by ReadSpeaker

item