A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Construct a c++ program to display Name and Average marks of student using keyboard Name - Shamika Marks - 86,75,59,94. Pls help me.

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    the best way to do that is to use arrays

  2. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I dnt stil get t. bt nyway thanx.

  4. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    What do you not understand?

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    First v shud write #include <iostream.h> I dnt get hw u write after dat.

  6. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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++.

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ha k.

  8. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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?

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ya.

  10. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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).

  11. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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?

  12. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    Do you understand so far?

  13. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ya.

  14. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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?

  15. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ya

  16. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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?

  17. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ya

  18. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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?

  19. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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.

  20. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ha k. it does.

  21. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    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.

  22. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    I hope I at least got you on the right track.

  23. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ya. thanx a lot 4 ur tremendous help

  24. jagatuba
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 8

    You are welcome.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.