Problem: C program for " If the marks obtained by a student in five different subject are input through the keyboard, find out the aggregate marks and percentage obtained by the student. Assume that the maximum that can be obtained by a student in each subject is 100."
Formulae used:
Aggregate marks = sub1 + sub2 + sub3 + sub4 + sub5
Average marks = aggregate marks / 5
Percentage = ( aggregate marks x 100 ) / 500
C program:
// Program by shyam kanth#include<stdio.h>int main(){int sub1, sub2, sub3, sub4, sub5, sum;float avg, per;printf("Enter the marks of five subjects : ");scanf(" %d %d %d %d %d",&sub1,&sub2,&sub3,&sub4,&sub5);sum=sub1+sub2+sub3+sub4+sub5;avg=sum/5;per = (sum*100)/500;printf("Total marks obtained : %d\n",sum);printf("Averge marks : %.2f\n",avg);printf("Percentage scored : %.2f\n",per);return 0;}
- #include <stdio.h> : Header file for input output
- int : Integer data type
- float : Decimal data type
- sub1, sub2, sub3, sub4, sub5, sum, avg, per : Variable used
- printf : Function for displaying message
- scanf : Function for taking input
Do comment, if any doubt
Know about me : Shyam Kanth
No comments:
Post a Comment