Pages

Write a program in c language to get numbers from user and print average.

Wednesday 10 July 2013

# include<stdio.h>
#include<conio.h>
#define LIMIT 130
int main(){
float marks[LIMIT], average, sum = 0.0;
int i=0;
do {
printf("\nEnter the mark of the student(-1 to finish)");
scanf("%f", &marks[i]);
if (marks[i] >= 0)
sum = sum + marks[i];
}
while(marks[i++] >= 0);
average = sum/(i-1);
printf ("\nThe average is %.2f\n", average);
getch();
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *