Friday, November 15, 2013

Comparison of Two Numbers


Code:


#include <iostream>
using namespace std;
void main()
{
 int a,b,c,d;
 cout << "Enter First Number: ";
 cin >> a;
 cout << "Enter Second Number: ";
 cin >> b;
 if (a>b)
 {
  cout << "***** Explanation about these numbers *****" << endl;
  cout << "Larger Number Is: " << a << endl;
  cout << a << " is larger than " << b << " by " << a-b << " units " << endl;
 }
 else
 {
  cout << "***** Explanation about these numbers *****" << endl;
  cout << "Larger Number Is: " << b << endl;
  cout << b << " is larger than " << a << " by " << b-a << " units " << endl;
 }
 if (a==b)
 {
  cout << "Both Numbers Are Equal" << endl;
 }
 else
 {
  cout << "Both Numbers Are Not Equal" << endl;
 }
 c = a%2;
 if (c==0)
 {
  cout << "First Number is Even" << endl;
 }
 else
 {
  cout << "First Number is Odd" << endl;
 }
 d = b%2;
 if (d==0)
 {
  cout << "Second Number is Even" << endl;
 }
 else
 {
  cout << "Second Number is Odd" << endl;
 }
 if(a>b)
{
 c = a%b;
 if(c==0)
  cout<<"Larger Number " << a << " is Multiple of Smaller Number " << b << endl;
 else
  cout<<"Larger Number " << a << " is not a Multiple of Smaller Number " << b << endl;
}

else
{
 c = b%a;
 if(c==0)
  cout<<"Larger Number " << b << " is Multiple of Smaller Number " << a << endl;
 else
  cout<<"Larger Number " << b << " is not a Multiple of Smaller Number " << a << endl;
}
 }

Widgets

 

Copyright @ 2014 CPP Fuzz.