Sunday, June 14, 2020
Program to calculate totalMarks, percentage and average of five subj
Write a C program to calculate total marks, percentage and average of five subjects of a student by taking marks as input from user using scanf() fucntion.
Before writing any program you just imagine about output screen first. For example: what input to be given, and output to be displayed. Let's have a look at the below example:
INPUT:
Enter secured marks of all subjects:
40
50
60
70
80
OUTPUT:
Total marks = 300.00
Percentage = 60.00
Average = 60.00
Logic to calculate total marks, percentage and average:
Step by step logic to calculate toatal marks, percenage and average.
1) Print a massage to the user like "Enter secured marks of all subjects:" using printf();
2) Input marks using scanf(); and store it in a variables: arbic, urdu, eng, hindi, and comp.
3) To get total marks sum of all subjects like: totalMarks = arbic + urdu + eng + hindi + comp
4) To calculate %, use this farmula : percentage = (totalMarks / 500) * 100
5) To calculate average use this farmula : average = totalMarks / 5
6) At last print the values of totalMarks, percentage and average. that's it!
Program to calculate totalMarks, percentage and average of all subjects:
Output:
Note: In above example: Statements scanf("%f%f%f%f%f", &arabic, &urdu, &hindi, &eng, &comp); format specifier %f is used for float data type.
And statements, printf("Total marks = %.2f\n", totalMarks); %.2f is used to print the number in decimal format upto 2 digits after dot. For Example: 300.00, 60.00 etc.
Visit to know more about Format specifier.
![](https://1.bp.blogspot.com/-lJ032BJI94Q/X4ipUPtN2GI/AAAAAAAACSs/cS6fBwan9yQBdk_fc6XRAhmocOOa2IPLQCLcBGAsYHQ/s320/Programming.png)
![](https://1.bp.blogspot.com/-zQn-y7fhFik/YLi8qbneaGI/AAAAAAAACrI/V_GVh5i94fssrE37V_AJiqgz21T8s9CAgCPcBGAYYCw/s320/Banner1.png)
![](https://1.bp.blogspot.com/-gmKYAtzLob0/X5KV37IV1sI/AAAAAAAACT8/v7-nc7S2pAUCDQpZvJgcBo17fOiZ37Q6wCLcBGAsYHQ/s320/Job%2BInterview%2BSkills.png)
![](https://1.bp.blogspot.com/-uOwbXCHRWi0/X5KV4Ox89UI/AAAAAAAACUA/XJTxI1jFv5s7HODVnBKXs5AVzaRg_FemgCLcBGAsYHQ/s320/WebDesigning.png)
![](https://1.bp.blogspot.com/-zQn-y7fhFik/YLi8qbneaGI/AAAAAAAACrI/V_GVh5i94fssrE37V_AJiqgz21T8s9CAgCPcBGAYYCw/s320/Banner1.png)
![](https://1.bp.blogspot.com/-gmKYAtzLob0/X5KV37IV1sI/AAAAAAAACT8/v7-nc7S2pAUCDQpZvJgcBo17fOiZ37Q6wCLcBGAsYHQ/s320/Job%2BInterview%2BSkills.png)
![](https://1.bp.blogspot.com/-1wlFAhlf1Tg/X4ipTqmsrWI/AAAAAAAACSk/hbA5yzIWIpQHFVM5Q8DzG9_U8-I0BsPJQCLcBGAsYHQ/s320/HW.png)
![](https://1.bp.blogspot.com/-gmKYAtzLob0/X5KV37IV1sI/AAAAAAAACT8/v7-nc7S2pAUCDQpZvJgcBo17fOiZ37Q6wCLcBGAsYHQ/s320/Job%2BInterview%2BSkills.png)
![](https://1.bp.blogspot.com/-HjTj0VEhg38/X5KV2TSF9nI/AAAAAAAACTk/dl0t2hQ3cP8nH8Vp2xnzClh3dGpyrBrbgCLcBGAsYHQ/s320/Blogging.png)
![](https://1.bp.blogspot.com/-PpK2776r0h4/X5KV34uGW9I/AAAAAAAACT4/EveLCjuu8R848djxa4Nkmantqa9O5pL8ACLcBGAsYHQ/s320/Interview%2BQ%2526A.png)
![](https://1.bp.blogspot.com/-zQn-y7fhFik/YLi8qbneaGI/AAAAAAAACrI/V_GVh5i94fssrE37V_AJiqgz21T8s9CAgCPcBGAYYCw/s320/Banner1.png)
Help others by sharing this page.
![](https://lh3.googleusercontent.com/-YHJx9KRn5n0/WFt46p7yV2I/AAAAAAAABJ4/VInfJae6dYEr6hPWsy62CWfKXXhVMi1HACEwYBhgLKtQDAL1OcqzCtoeJ-i2dap0xXlyTzO7oa4gl7ISXXXUU3JFpJ-1I9ZoLTzaXCWKFnc8lqUtjI4GDkkfuHpmhrLbzmW8MCTjsV9eU7pCZzjuNDsRH2O0toLnmE-WwxjhMHW4ANmE36hxVPCjEe5yUsts1kkh3D-ieuhWfuTY4y_qy8B931M08I6w8B2QLoa-ecdFIopHhBZUXJzV7uT_gFXLCOUa2VxYrbzjLVFRyJXgnBDkPakqLtbSMLabAOhBGDssBAyPoXT0ba1UvwTroN0-UXcTY-UjnlC73V957_IX6HtWUnTIW4--Y_ztDWOAYgGWoDjHWgmVkFOB98diRcRVXjieHHGALfnQKUQuIddHsAA2dP1bkVXI94B2EHegYQRut3zDK3246xhbWrOn7ZoFri2zF_uMUAV3XFkeAIMnADvOF4yKwyx_ehH0xPkj1x3fensBVm7JH1uEI-Eg9zv_dJN_pZHdCNO9tobyDYruKvY8pTHxtpLyZSDzJHLoVs6ovr7_dspUkASUw5DMIlIHFJoVymq0mszqBrypz3d55fQjjZV6WKSq5xJeKPR6uNfw-r3kERqE53oXnhum5rGY_fSoqyMAwdSJkktSt4Pz5z0EDcf6IMNDH7PsF/w139-h140-p/WP_20161029_16_18_44_Selfie.jpg)
Ahmad Irshad
Author & Editor
I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP
Sunday, June 14, 2020
C
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment
Please don't enter any spam link in the comment box.