initial import
[staff/goc4/2018bti7061.git] / c-2-controlStructures / examples / controlStatements / average.c
1 #include <stdio.h>
2
3 main(){
4
5 char name[80];
6 int nbMarks,i=0;
7 float mark, sum, avg;
8 puts("Hello, what is your name?");
9 /* scan a line : everything not \n */
10 scanf(" %[^\n]",name);
11 printf("Number of marks?");
12 scanf(" %d",&nbMarks);
13 while (i<nbMarks){
14 i++;
15 printf("Enter Mark %d:",(i));
16 scanf(" %f",&mark);
17 sum += mark;
18 }
19 avg = sum / nbMarks;
20
21 printf("%s, your average mark is: %.1f \n",name,avg);
22
23 }