Saturday, October 30, 2010

Program to sum of five elements of an array

PROGRAM 2

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

void main ()
{
 int no[5],i,sum;
 clrscr ();
 for (i=0;i<=4;i++)
 {
   printf ("Enter Element: ");
   scanf ("%d",&no[i]);
}
 sum=no[0]+no[1]+no[2]+no[3]+no[4];
 printf ("\nSum of five Elements: %d",sum);
 getch (); 
}

OUTPUT

Enter Element:3
Enter Element:4
Enter Element:55
Enter Element:10
Enter Element:9
Sum of five Elements:81

0 comments:

Post a Comment