#include <iostream>
usingnamespace std;
int main()
{
int a, b, c, d, e
cout<<"please enter a number";
cin>>a;
cout<<"please enter another number";
cin>>b;
cout<<"please enter the last number";
cin>>c;
d=a>b
e=b>a
if (a>c) {
cout>>"the greatest number is">>a;
elseif (c>a) {
cout>>"the greatest number is">>c;
}
}
This was in class. It prompts the user to enter 3 integer, and output which one is the greatest integer as the result. It was done on Microsoft visual C++ 10.
debugged it and 1 failed error about linkers. Turned that off and still won't compile.
am i doing something wrong? please point it out and is there other ways u can do this. thanks
#include <iostream>
usingnamespace std;
int main()
{
int a, b, c;
cout<<"please enter a number:\t";
cin>>a;
cout<<"please enter another number:\t";
cin>>b;
cout<<"please enter the last number:\t";
cin>>c;
if(a > b && a > c)
{
std::cout << a << " is your biggest number.";
}
if(b > a && b > c)
{
std::cout << b << " is your biggest number.";
} else {
if(c > a && a > b)
{
std::cout << c << " is your biggest number.";
}
}
}
#include <iostream>
usingnamespace std;
int checkNumber(int x, int max)
{
if(x > max)
{
cout << "This is too high!";
returnfalse;
}
returntrue;
}
int main()
{
bool pass;
int a, b, c;
constint MAX_NUM = 100;
cout<<"please enter a max number of " << MAX_NUM<< ":\t";
cin>>a;
pass = checkNumber(a,MAX_NUM);
if(pass == false)
{
return -1;
}
cout<<"please enter another max number of " << MAX_NUM<< ":\t";
cin>>b;
pass = checkNumber(a,MAX_NUM);
if(pass == false)
{
return -1;
}
cout<<"please enter the last max number of " << MAX_NUM<< ":\t";
cin>>c;
pass = checkNumber(a,MAX_NUM);
if(pass == false)
{
return -1;
}
if(a > b && a > c)
{
std::cout << a << " is your biggest number.";
}
if(b > a && b > c)
{
std::cout << b << " is your biggest number.";
} else {
if(c > a && a > b)
{
std::cout << c << " is your biggest number.";
}
}
}