Вы находитесь на странице: 1из 1

//Reverse and sum #include<iostream.h> #include<conio.

h> int main() { clrscr(); long int x,y,temp; cout<<"Enter a number: "; cin>>x; int s = 0,digit; temp=x; y=0; while (temp!=0) { digit= temp%10; y = y*10 + digit; s= s+digit; temp=temp/10; } cout<<"\nOriginal No.: "<<x; cout<<"\nInverse No.: "<<y; cout<<"\nSum of digits.: "<<s; getch(); return 0; } /* Enter a number: 1324 Original No.: 1324 Inverse No.: 4231 Sum of digits.: 10 */

Вам также может понравиться