Calculate total score and average score

Source: Internet
Author: User
Tags ming

Xiao Ming has a total of 5 courses this semester, namely English, Chinese, maths, history and music. The mid-term examinations of 5 subjects were 86 points, 74 points, 92 points, 77 points, 82 points, and the final exam results were 81 points, 87 points, 90 points, 62 points and 88 points respectively. Known midterm and final exam scores accounted for 30% and 70% of the total score respectively. Define the corresponding variables to store the scores of each subject, and calculate the total score of Xiao Ming's 5 courses in peace and sharing. Requires an average output of two forms: a floating-point number with 2 decimal places and an integer form without decimals. A floating-point number with a 2-bit decimal number is required for total output. The data types of floating-point numbers in the program are float types.

Tips:

An integer that outputs an average score without a decimal can use coercion type conversions.


The following are examples of output:

total=408.90

average=81.78

average=81


input format: None

output Format:

Output Total score format: "total=%.2f\n"

Format of output average: "average=%.2f\n"

"Average=%d\n"

#include  <stdio.h>

int main ()
{
	float total,average;
	Total= (86+74+92+77+82) *0.3+ (81+87+90+62+88) *0.7;
	AVERAGE=TOTAL/5;
	printf ("total=%.2f\n", total);
        printf ("average=%.2f\n", average);
    	return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.