Wednesday 27 June 2012

c++ program that take input one number and display it in reverse and also calculate sum of series.


#include <iostream>
using namespace std;

int main()
{
int a;
int num;
int sum = 0;
cout<<"Enter the no:";
cin>>a;
num=a;
cout<<"Reverse number is:- ";
while(a!=0)
{
cout<<a%10;
a=a/10;
}


while ( num > 0 )
{
sum += num % 10;
num /= 10;
}

cout << "Sum = " << sum;

return 0;
}











No comments:

Post a Comment