21 January, 2013

C Program For Addition Of 'N' Numbers.

This Post Contains A C Program For Addition Of 'N' Numbers With Correct Source Code & Output.
This Program Is Written, Compiled & Executed At TurboC3.0 Compiler & Will Help You To Understand The Concept Of ''For-loop' From C Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple
& Easy-To-Understand Way.

# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.


C Program For Addition Of 'N' Numbers.

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

void main()
{
    int i=0,Num=0,Sum=0;
    clrscr();
    printf("\n Please Enter The Number : \t");
    scanf("%d",&Num);
    for( i=0 ;i  <= Num ; i++ )
    {
        Sum = Sum + i;
    }
    printf(" \n The Addition Of Nos Till %d Is : \t %d ", Num, Sum );

    getch();
}

Output :

Please Enter The Number  :  10

The Addition Of Nos Till 10 Is  :  55




No comments:

Post a Comment

Subscribe To:

Most Commonly Asked Programs In 'C' & 'C++' Language.