answersLogoWhite

0

The following example sets up a two-dimensional array, initialises it with some pseudo-random data, and then prints the table and the averages.

#include<iostream>

#include<time.h>

int main()

{

const int max_students = 7;

const int max_student_grades = 5;

const int max_grades = 6;

const char grade[max_grades]={'A','B','C','D','E','F'};

srand((unsigned) time(NULL));

// Initialise the array with pseudo-random grades:

int table[max_students][max_student_grades];

for(int student=0; student<max_students; ++student)

{

for(int student_grade=0; student_grade<max_student_grades; ++student_grade)

{

table[student][student_grade] = rand()%max_grades;

}

}

// Print the table and average the results.

int overall=0;

for(int student=0; student<max_students; ++student)

{

int average=0;

std::cout<<"Student #"<<student+1;

for(int student_grade=0; student_grade<max_student_grades; ++student_grade)

{

std::cout<<" Grade #"<<student_grade+1<<": "<<grade[table[student][student_grade]]<<", ";

average+=table[student][student_grade];

}

std::cout<<" Average: "<<grade[average/max_grades]<<std::endl;

overall+=average;

}

std::cout<<"Overall average: "<<grade[overall/max_grades/max_students]<<std::endl;

return(0);

}

Example output:

Student #1 Grade #1: A, Grade #2: E, Grade #3: D, Grade #4: E, Grade #5: F, Average: C

Student #2 Grade #1: E, Grade #2: D, Grade #3: E, Grade #4: E, Grade #5: E, Average: D

Student #3 Grade #1: D, Grade #2: A, Grade #3: D, Grade #4: B, Grade #5: A, Average: B

Student #4 Grade #1: C, Grade #2: B, Grade #3: A, Grade #4: A, Grade #5: B, Average: A

Student #5 Grade #1: E, Grade #2: D, Grade #3: C, Grade #4: F, Grade #5: E, Average: D

Student #6 Grade #1: C, Grade #2: D, Grade #3: A, Grade #4: F, Grade #5: A, Average: B

Student #7 Grade #1: B, Grade #2: D, Grade #3: F, Grade #4: B, Grade #5: C, Average: C

Overall average: C

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

How is scanning of programming useful to students?

It helps students think about why certain chunks of code are there and how they affect the program itself. This helps in programming, as once you see a block of code that does one job, you can usually replicate it within your own work to bypass problems.


What jobs can you get with an associates degree in computer programming?

Wondering the same, wish someone would answer. With associate degree in computer programming you can get an entry-level programming job in a fairly short amount of time. It can also be used as a stepping stone to a bachelors degree in a technology field. Associate degree in computer programming give students hands-on skills they need to be productive software developers in many industries, using specific skill sets and programming languages.


How does HTML helps programming students?

It is important to note that HTML is not a programming language. It is a markup language. However, it does have some similar characteristics, like that it is a file with a list of commands, it has rules, it allows comments and other things. It is easy to learn and can be useful to get people used to the basic concept of giving instructions to a computer in a file. However there are lots of fundamentals of programming that are not in HTML, as it is not a programming language. For serious programming courses, people would not be shown HTML as part of the training. They would start on an actual programming language to be shown the fundamentals of programming. Some programming can be linked into web pages, and so integrated with HTML and if people are going to be creating programs for the internet, then they would learn HTML.


What is the programming language in 1964?

In 1964, the programming language BASIC (Beginner's All-purpose Symbolic Instruction Code) was developed by John G. Kemeny and Thomas E. Kurtz at Dartmouth College. BASIC was designed to provide an accessible way for students and beginners to learn programming, making it easier to interact with computers for educational purposes. This language played a significant role in popularizing programming among a wider audience.


What programming language revolutionized the software industry because begi9nning students could learn it easy?

According to the scenario of bangladesh, php and .Net is now the king and java is the grand pa

Related Questions

Why are brilliant math students so terrible at computer programming?

Well Maths students are Focused on Calculating Not Programming Where as those who suck in maths will be Like awesome in Computer Programming. Like me .


The students did well on the test give you 4 variables?

the 4 variables are poorly disappointing angry and frustrated


Why are brilliant math students so terrible at programming languages?

Because they don't get proper guidence of a knowlegable programming teacher who will built them from basic/abc to top of programming languages.


What are the uses of Arithmetic Mean?

The arithmetic mean is used in fields like statistics and economics. The arithmetic mean is the average of a group of numbers. It can be used to find test averages for students and in sports to find player averages


How do you teach variables in your classroom?

Variables are introduced as placeholders that can hold different values. I teach students how to declare variables, assign values to them, and use them in mathematical expressions or conditions. We practice using variables in various problem-solving scenarios to reinforce their understanding.


Can students of department of Modeling and Industrial Computing do C plus plus programming?

Yes.


What can be a good title for graphs for students?

It should consist of a short description of the variables which are plotted.


Hich of these students displays an example of the impulsivity symptom of ADHD?

Mario is impatient and will not take turns in an activity


How is scanning of programming useful to students?

It helps students think about why certain chunks of code are there and how they affect the program itself. This helps in programming, as once you see a block of code that does one job, you can usually replicate it within your own work to bypass problems.


What has the author B Ratcliff written?

B. Ratcliff has written: 'Introducing ALGOL 68 and structured programming to non-computer science students as their first programming experience'


What is the major use of theory of computation?

Its a theory specially addressed to computing students and programming developers.


Should students grades in gym affect their grade point averages?

Yes. Gym, physical education, is as important as every other class.