Tuesday, 31 July 2018

Details of a Four Digit Number

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



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

void main()
{
   clrscr();
   int n,a,b,c,d,s,r;
   cout<<"\n Enter a Four Digit number: ";
   cin>>n;
   a=n%10;
   n=n/10;
   b=n%10;
   n=n/10;
   c=n%10;
   n=n/10;
   d=n%10;
   s=a+b+c+d;
   r=1000.0*a+100.0*b+10.0*c+1.0*d;
   cout<<"\n\n    The Sum of the digits of the number is: "<<s;
   cout<<"\n\n    The Reverse of the number is: "<<r;
   cout<<"\n\n    The number in Expanded form is:- ";
   cout<<"\n      ¯ Thousand Place: "<<a;
   cout<<"\n      ¯ Hundered Place: "<<b;
   cout<<"\n      ¯ Tens Place: "<<c;
   cout<<"\n      ¯ Ones Place: "<<d;
   getch();
}



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


                                OUTPUT


No comments:

Post a Comment