PROJECT: Sum of n Numbers.

Learn and Trouble Shoot Problems Related to C-Language here.

PROJECT: Sum of n Numbers.

Unread postby rajeevmahura » Thu May 22, 2008 6:04 pm

#include<stdio.h>
#include<conio.h>
void main()
{

int data[20],sum=0,cho,i;
clrscr();
printf("How Many Numebrs Do You Want Enter ");
scanf("%d",&cho);

for(i=1;i<=cho;i++)
{
printf("Enter Any Numebr for Data[%d] ",i);
scanf("%d",&data[i]);

sum=sum+data[i];
}
printf("\n\n\tThe Sum of %d Numbers is: %d",cho,sum);

getch();
}
----------------------------------------------------------------
Input: cho=3,data[1]=1,data[2]=2,data[3]=3
Output: The Sum of 3 Numbers is: 6
--Regards--
Rajeev Mahura
Servers & Storage Professional
http://about.me/rajeevmahura
User avatar
rajeevmahura
 
Posts: 144
Joined: Tue May 20, 2008 5:22 pm
Location: Bangalore | New Delhi
Full Name: Rajeev Mahura
Date Of Birth: 15 Jan 1984
Address: New Delhi
Profession: DOEACC Trainer
DOEACC Center: DOEACC DELHI
Mobile No: 0

Return to C-Language

Who is online

Users browsing this forum: No registered users and 2 guests

cron