Project: Enter Numbers in Array and sum of Entered Numbers

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

Project: Enter Numbers in Array and sum of Entered Numbers

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

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,sum=0,i;
clrscr();
printf("How Many Numbers You Want Entered ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter %d Number:- ",i);
scanf("%d",&a[i]);
sum=sum+a[i];
}

for(i=1;i<=n;i++)
{
printf("\n\n%d Number:- %d ",i,a[i]);
}
printf("\n\n\t\tSum of %d Numbers is:- %d",n,sum);
getch();
}
-------------------------------------------------------------
Input: n=3,a[1]=2,a[2]=5,a[3]=9
Output: 1 Number:- 2
2 Number:- 5
3 Number:- 9

Sum of 3 Numbers is:- 16
--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 1 guest

cron