How do you write a program in C++ that prints out asterisks for every student that has a certain grade?
You would use a if statement with a condition that the students grade equals that of the predetermined 'certain' grade. If this 'if' statement evaluates to true then it would print out an asterisk using the cout function. This 'if' statement would reside inside a for or while loop, so that it may go through each of the students grades. The for or while loop would need a condition which stops it when you have reached the end of the list of student grades. In addition you would need some way of moving through this list of student grades using some sort of index variable (easily done with the for loop).
you could take it a step further, and have a while loop have you input as many grades as you want, and save them to an array- and you can make a sentinel value (something you enter such as -1 that will stop the loop from asking you again) then use another loop determined by how many arrays you made to add asterisks if that grade is in that certain range.
Join our real-time social learning platform and learn together with your friends!