anonymous
  • anonymous
Construct a c++ program to display Name and Average marks of student using keyboard Name - Shamika Marks - 86,75,59,94. Pls help me.
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
the best way to do that is to use arrays
jagatuba
  • jagatuba
Agreed. I don't know C++ syntax, but you will want to store your marks values in a marks array, then you can easily find the average by using a loop to add all the values and then divide by the size of the array.
anonymous
  • anonymous
I dnt stil get t. bt nyway thanx.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

jagatuba
  • jagatuba
What do you not understand?
anonymous
  • anonymous
First v shud write #include I dnt get hw u write after dat.
jagatuba
  • jagatuba
I do not write C++ programs so I cannot tell you what to write, I can just tell you how to do it. You have to translate that into C++.
anonymous
  • anonymous
Ha k.
jagatuba
  • jagatuba
If I understand right, what the program is supposed to do is take input from the user (name and marks) then display the name and the average of the marks. Is this correct?
anonymous
  • anonymous
Ya.
jagatuba
  • jagatuba
So the easy part is the name. You are simply going to prompt the user for a name and store that in a variable (n, Name, or whatever you ant to call it).
jagatuba
  • jagatuba
Then you are going to want to prompt the user for the marks of the student. this needs to be set up in a loop so that the user can keep entering marks until done. You need to have a check in the loop that looks for an input that indicates that the user is done entering marks. Looking for a value less than zero is good because there are not marks that are less than 0 so it the user enters -1 then the loop kicks out. Following me so far?
jagatuba
  • jagatuba
Do you understand so far?
anonymous
  • anonymous
ya.
jagatuba
  • jagatuba
Okay. So for your loop that takes the marks input you are going to want to have an array set up. An array is a variable that can hold more than one value. You can think of it like a line of cubbyholes that you can put similar values into. By similar I mean that the values have to be all of the same data type (int, double, float, etc.). When you set up your array you need to be sure to give it enough space to store all of your marks (it has to have enough cubbyholes) so set the capacity of the array higher than the most number of marks that will be entered. Are you still understanding all this?
anonymous
  • anonymous
ya
jagatuba
  • jagatuba
Okay. So once you have an array set up you can use it to store the inputs by using an iterative value in your loop as the array's address. For example, if you use a while loop set up a variable i so that it increments by 1 on each pass through the loop and use i as the address value of your array. So when you assign the marks entered you will be assigning them to consecutive cubbyholes. mark[i]=markEntry Something like that. You still following me?
anonymous
  • anonymous
ya
jagatuba
  • jagatuba
Be sure to have your array value assignment statements after your exit check otherwise you will have an erroneous value in your array (like -1 or -742) that will mess up your calculations. So now that you have a loop that asks for marks and assigns them to the array all that is left is to display the name, which is easy enough using a print statement and display the average. To calculate the average you are going to set up a similar loop as before, but this time you are going to be retrieving the numbers from the array rather than storing them. In this case it is easier to use a for loop. you will make the for loop iterate the same number of times as the number of values stored in your array. SO: for r = 0 to length (mark[]); r++ //this is just pseudocode, use C++ syntax Now for each iteration of the loop you will add the value of mark[r] to another variable, say average: average=average+mark[r] This will loop for the length of the array and then exit right after the exit you will calculate the average with average=average/length{mark[]) //pseudo code Then you just display the average with a print statement. Does that make sense?
jagatuba
  • jagatuba
Oh and I made a slight error in my pseudo code. Since array addresses start at 0 you want to use length(mark[])-1 as your limit.
anonymous
  • anonymous
ha k. it does.
jagatuba
  • jagatuba
If you have any trouble with your program you can post it on here and someone can look at it and help you. We do have C++ programmers on here, but none of them appear to be here right now.
jagatuba
  • jagatuba
I hope I at least got you on the right track.
anonymous
  • anonymous
ya. thanx a lot 4 ur tremendous help
jagatuba
  • jagatuba
You are welcome.

Looking for something else?

Not the answer you are looking for? Search for more explanations.