0

i need to fix thiis problem is very needed in my first program class. hoping for your kind help

problem; create a program that will determine the highest number. it should be a user defined and use while and if-else statement only.

11th Nov 2022, 6:56 AM
Joar
4 Respostas
+ 2
What have you tried so far? Please link your code. An idea for the implementation: - you start with an array of numbers - create a variable called max and store the first element of the array in it - loop through all elements (except the first one) - inside the loop you compare the current element with the value of max - change max, if the current element is higher
11th Nov 2022, 8:09 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Part 1 Break down your problem into smaller parts and try to solve it. Following can be few good starting points. - Check with your professor how are you going to receive input. - Try to Google how you read input - Which data type should you use to store the info. - Now try to formalize a strategy on how you normally find highest number. Not in code just simply how your brain processes it. - Next ask some questions - so do I need some variable and compare it or any other way I can do? - Go to Google and read more about while and if else condition. - Try to write the code, there may be some compile issues or wrong answer. In that case, you need to debug. Part 2 Basic Debugging - You should understand what your code is trying to do. Even if it's non working code. - Place cout statements printing the variables or info to understand flow. - In end, still not able to found out the issue. Post in forum, reach out to teacher or friends. It is very important that you know what went wrong.
11th Nov 2022, 8:59 AM
Suzan
Suzan - avatar
+ 2
Part 3 Advance steps - Ask about constraints - What is the range of numbers we are dealing with? This would help you to decide whether should you use int or long or any other type? - Also, are decimal places allowed or not. As the question doesn't have info on what type we are dealing with integers or decimals as well? - Does my code has meaningful variable names? - Is my code clean? You can read starting chapters of Clean Code book.
11th Nov 2022, 9:00 AM
Suzan
Suzan - avatar
0
Hi
12th Nov 2022, 1:10 PM
MD Atikur
MD Atikur - avatar