For my homework assignment, I'm supposed to get five numbers from a user and print the highest one using a loop. I'm not sure what to do. Any suggestions?
sfurlow2 0 Light Poster
Recommended Answers
Jump to Postsuggestion
int main() { // put your code here return 0; }
Ok, so lets assume you know how to do the above. You need a for/next loop that counts from 0 to 5, display a prompt, get input using cin, then keep track of the highest …
Jump to Postby having a variable ( i.e. int highest; ) and using an if statement after the cin to check if it is higher or lower than the one they just input, then keep the higher of the two stored there....
Jump to Postok, should more look something like this:
#include <iostream> //needed for cout and cin using namespace std; //also needed... int main(){ int counter = 0; int highest = 0; int input = 0; for(counter = 1; counter <= 5; counter++){ //input the number from the user. cin …
Jump to Post(ummm.... i wasn't the one having the problem with the code, i know for a fact that the code i posted works... i was posting it so sfurlow2 could see how to do it, else i wouldn't have commented it i would just have put a code snipet for all …
All 13 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sfurlow2 0 Light Poster
evilsilver 0 Junior Poster in Training
sfurlow2 0 Light Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
evilsilver 0 Junior Poster in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
evilsilver 0 Junior Poster in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
sfurlow2 0 Light Poster
sfurlow2 0 Light Poster
VernonDozier 2,218 Posting Expert Featured Poster
sfurlow2 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.