hello, i am a beginner in C++
this is the code i wrote for finding largest number using xcode IDE
it doesnt show any errors, but doesnt give output either.
here is the output:
enter the value of and b 1 4
The largest value is:
0Program ended with exit code: 0
#include<iostream>
usingnamespace std;
class LargestValue
{
public:
int a;
int b;
int large;
int input(void);
int largest(void);
int display(void);
};
int LargestValue::input(void)
{
std::cout<<"enter the value of and b";
std::cin>>a>>b;
return (static_cast<void>(a),b);
}
int LargestValue::largest(void)
{
if (a>b)
{large=a;
return a;}
large=b;
return b;
}
int LargestValue::display(void)
{
std::cout<<"The largest value is:\n"<<large;
return large;
}
int main(int argc, constchar * argv[])
{
LargestValue A;
A.input();
A.display();
A.largest();
return 0;
}
#include <iostream>
class LargestValue
{
private:
int a;
int b;
int large;
public:
void input();
void largest();
void display();
};
int main()
{
LargestValue A;
A.input();
A.largest();
A.display();
}
void LargestValue::input()
{
std::cout << "enter the value of and b: ";
std::cin >> a >> b;
}
void LargestValue::largest()
{
if (a > b)
{
large = a;
}
large = b;
}
void LargestValue::display()
{
std::cout << "The largest value is: " << large << '\n';
}
enter the value of and b: 5 12
The largest value is: 12