-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-1-15.c
More file actions
44 lines (37 loc) · 1.04 KB
/
exp-1-15.c
File metadata and controls
44 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*************************************************************************
> File Name: exp-1-15.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Tue Jun 27 17:02:24 2017
************************************************************************/
/*
* Write a C program to enter marks of five subjects and calculate total, average and percentage.
*
* Example
*
* Input
* Enter marks of five subjects: 95 76 85 90 89
*
* Output
* Total = 435
* Average = 87
* Percentage = 87.00
*
*/
#include <stdio.h>
int main()
{
float n1, n2, n3, n4, n5;
float total, average, percentage;
/* read marks of five subjects from user */
printf("Enter marks of five subjects: \n");
scanf("%f%f%f%f%f", &n1, &n2, &n3, &n4, &n5);
/* calculate total, average and percentage one by one */
total = n1 + n2 + n3 + n4 + n5;
average = total / 5;
percentage = (average / 500) * 100;
printf("Total marks is %.2lf\n", total);
printf("Average marks is %.2lf\n", average);
printf("Percentage is %.2lf\n", percentage);
return 0;
}