It can Calculate by four operations (+ - * /)
Also tells which input number is greater!
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n, a, b, c, d,e,f;
cout << "Enter a two digit number : ";
cin >> n;
if (n >= 10 && n <= 99)
{
cout << "Its a two digit number";
a = n % 10;
b = n / 10;
c = a + b;
if (c >= 10)
{
d = c / 10;
e = c % 10;
f = d + e;
cout << "The sum is : " << f << endl;
}
else
cout << "The sum is : " << c << endl;
}
return 0;
}
Also tells which input number is greater!
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n, a, b, c, d,e,f;
cout << "Enter a two digit number : ";
cin >> n;
if (n >= 10 && n <= 99)
{
cout << "Its a two digit number";
a = n % 10;
b = n / 10;
c = a + b;
if (c >= 10)
{
d = c / 10;
e = c % 10;
f = d + e;
cout << "The sum is : " << f << endl;
}
else
cout << "The sum is : " << c << endl;
}
return 0;
}
No comments:
Post a Comment