I am working on a console application that is to take inputs from the user and output the largest so far only the first two inputs seem to work, the last three are ignored, please help resolve this.
// This program accepts five numbers from the user and outputs the largest number entered.
#include <iostream>
#include <cmath>
using namespace std;
int score, number1, number2, number3, number4, number5;
It's easier to store the maximum number in a separate variable and then determine its value by comparing to the numbers one by one. Something like:
int maxNum = number1;
if (number2 > maxNum) maxNum = number2;
if (number3 > maxNum) maxNum = number3;
if (number4 > maxNum) maxNum = number4;
if (number5 > maxNum) maxNum = number5;
cout << "The highest score is " << maxNum << '\n';
Better still, store the numbers in a vector. That way you can compute the maximum regardless of how many there are by putting the code in a loop.