C Programming

Solved Example

Practice Questions

Exercise Question

Find the avg of a student marks

Objective

Input 3 subject marks of a student and find the avg (Percentage) of the student. Assume the maximum marks of a subject is 100.

Program

#include<stdio.h>
int main() {
	int m1,m2,m3;
	float avg;
	
	printf("Enter 3 subject marks: ");
	scanf("%d%d%d",&m1,&m2,&m3);
	
	avg = (m1 + m2 + m3) / 3.0f;
	
	printf("Avg = %.2f",avg);
	return 0;
}

Sample Output

Enter 3 subject marks: 78 58 89
Avg = 75.00