Friday 14 March 2014

C Program to calculate average marks of 30 students using array

/* Use of array */
/* Program to calculate average marks of 30 students */
main( )
{
int  avg, sum = 0 ;
int  i ;
int  marks[30] ;  /* array declaration */
for ( i = 0 ; i <= 29 ; i++ )
{
printf ( "\nEnter marks " ) ;
scanf ( "%d", &marks[i] ) ;  /* store data in array */
}
for ( i = 0 ; i <= 29 ; i++ )
sum = sum + marks[i] ;  /* read data from an array*/
avg = sum / 30 ;
printf ( "\nAverage marks = %d", avg ) ;
}

No comments:

Post a Comment