WAP in turbo C++ to accept any two no.s from the user.If the first no is greater than the second no. then display square of the smaller no and cube of the greater no. If otherwise,vice versa. If the no.s are equal , display both no.s are equal.
Answers
the code are with the attachment....
hope it helps you..
Sample Program in C++:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a,b;
cout<<"Enter first number:";
cin>>a;
cout<<"Enter second number:";
cin>>b;
if(a > b)
{
cout << "\nThe cube of a 1st number is:" <<pow(a,3);
cout<< "\nThe square of a 2nd number is:" <<pow(b,2);
}
else if(b > a)
{
cout << "\nThe square of a 1st number is:" << pow(a,2);
cout<< "\nThe cube of a 2nd number is:" << pow(b,3);
}
else if(a == b)
{
cout<<"Both are equal";
}
return 0;
}
Output:
(i)
Enter first number: 5
Enter second number: 4
As a > b
The cube of a 1st number is: 125
The square of a 2nd number is: 16.
(ii)
Enter first number: 4
Enter second number: 5
As b > a
The square of a 1st number is: 16
The cube of a 2nd number is: 125
(iii)
Enter first number: 4
Enter second number: 4
Both are equal.