Tuesday, 31 July 2018

Who has Greater Magnitude?

===========================================================================
                                CODING



#include<conio.h>
#include<iostream.h>
#include<math.h>

void main()
{
clrscr();

int b,c,d,e,f,g,h,i,j,k,q,r;
long a,z,n,m;
cout<<"\n¯Enter any five digit number:- ";
cin>>a;
cout<<"\n¯Enter another five digit number:- ";
cin>>z;
n=a;
b=a%10;
a=a/10;
c=a%10;
a=a/10;
d=a%10;
a=a/10;
e=a%10;
a=a/10;
f=a%10;
a=a/10;
m=z;
g=z%10;
z=z/10;
h=z%10;
z=z/10;
i=z%10;
z=z/10;
j=z%10;
z=z/10;
k=z%10;
z=z/10;
q=b+c+d+e+f;
r=g+h+i+j+k;
if (q>r)
{cout<<"\n "<<n<<" has greater Magnitude i.e. the sum of the digits of "<<n<<"(i.e. "<<q<<") is greater than sum of the digits of "<<m<<"(i.e. "<<r<<")";}
else
{cout<<"\n "<<m<<" has greater Magnitude i.e. the sum of the digits of "<<m<<"(i.e. "<<r<<") is greater than sum of the digits of "<<n<<"(i.e. "<<q<<")";}
getch();
}



===========================================================================


                                OUTPUT



No comments:

Post a Comment