mustish1
asked on
Largest number
Hi guys: Can any one please tell me what i made mistake as it dont shows the largest number. Thanks.
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int x = 0 , max = 0;
cout << "Please input number, input a negative value to find largest number:";
cin >> x;
while(x >= 0)
{
if ( x > max)
max = x;
x++;
}
cout << "The largest number is: ";
cout << max;
system("pause");
return 0;
}
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int x = 0 , max = 0;
cout << "Please input number, input a negative value to find largest number:";
cin >> x;
while(x >= 0)
{
if ( x > max)
max = x;
x++;
}
cout << "The largest number is: ";
cout << max;
system("pause");
return 0;
}
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER