initial import
[staff/goc4/2018bti7061.git] / c-2-controlStructures / examples / inputsoutputs / interactive.c
1 #include <stdio.h>
2
3 main(){
4
5 char name[80];
6 int nbMarks,i;
7 double 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 for(i=0;i<nbMarks;i++){
14 printf("Enter Mark %d:",(i+1));
15 scanf(" %lf",&mark);
16 sum += mark;
17 }
18 avg = sum / nbMarks;
19
20 printf("%s, your average mark is: %.1lf \n",name,avg);
21
22 }