Record a class performance practice one-dimensional array

Source: Internet
Author: User

Directly on the code, mark: Hey.

#include <stdio.h>/** * Record and count the results of a class of students * practice the use of one-dimensional arrays */intMainvoid){intCount printf"How many students is in your class?\n"); scanf"%d", &count);//Get the number of students in the class    /** * I read in the book that it is not allowed to assign a variable to this, but * in my attempt is possible, do not know how. */    intNumbers[count],chinese[count],maths[count],eng[count]; Puts"Please input the StudentID and three scores:\n"); printf"StudentID Chinese Math english\n");inti =0;/** * Accept user's score input */     for(i =0; i < count;i++) {printf ("No.%d>", i+1); scanf"%d %d%d%d", &numbers[i],&chinese[i],&maths[i],&eng[i]); }/** * After the input is completed, the output user's score and their average score */printf"ID CH MA EN ave\n"); printf"--------------------------\ n");intJ for(j =0; J < count;j++) {floatAve = (Chinese[j] + maths[j] + eng[j])/3;//Find out the average scoreprintf"%d\t%d\t%d\t%d\t%f\n", Numbers[j],chinese[j],maths[j],eng[j],ave); }/** * Cycle to find the total scores of each section * *    floatAve_chinese =0, ave_math=0, Ave_english =0;intM for(M =0; m < count;m++) {Ave_chinese + = chinese[m];        Ave_math + = Maths[m];    Ave_english + = Eng[m]; }//Output average scoreprintf"The Average of Chinese in this class is%f\n", Ave_chinese/count); printf"The Average of math in this class is%f\n", Ave_math/count); printf"The Average of 中文版 in this class is%f\n", Ave_english/count);return 0;}

Here are the results of my program's operation:

Record a class performance practice one-dimensional array

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.