-1

How can we print the same list of the numbers in the output given by the user by using the loop before print the answer in c++?

Example:

Find the largest number in the list
We can get the list of the numbers by the user one by one by using loop are: 2,6,7,1,9

Output:

List of the numbers is : 2,6,7,1,9
The largest number is : 9

I am trying to solve this problem but i do not get the required answer

New contributor
Muhammad HASNAAT is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4
  • 3
    Please show what you have done so far. Include your code.
    – André
    Commented 2 days ago
  • 2
    How much C++ do you know? Do you know how to read input from the user? Do you know about vectors? Do you know how to loop over all elements of a vector? Do you know how to compare two variables, and how to assign one variable from another? Then you really know all you need to solve this assignment. Commented 2 days ago
  • 2
    Also, you don't need to store all the numbers to get the largest one. You only need to keep track of the largest so far, and replace it if you find something bigger.
    – BoP
    Commented 2 days ago
  • 1
    Start by figuring out how you would keep track of the largest number if you all you had was a pencil, some paper, and had some dude shouting numbers at you. Stupid human tricks always work on a computer, and often leave you with an algorithm with output you can inspect for patterns to exploit when writing version 2. Commented 2 days ago

0

Browse other questions tagged or ask your own question.