Tuesday, 19 June 2018

Program to calculate sum of an array of 5 element in C

/* sum of an array */
# include <stdio.h>
void main ()
{
int a[5] , i ;
int sum = 0 ;
clrscr () ;
for ( i=0 ; i<5 ; i++ )
{
printf ("\n Enter a number:") ;
scanf ("%d", & a[i]) ;
}
for ( i=0 ; i<5 ; i++ )
sum = sum + a[i] ;
printf ("\n sum = %d", sum) ;
getch () ;
}


No comments:

Post a Comment

Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...