Trending This Week:

test

Post Top Ad

Your Ad Spot

Thursday, June 9, 2022

c++ program to reverse a number


c++ program to reverse a number

#include <iostream>

using namespace std;

int main() 

{

    int n, rem=0, reverse;

    cin>>n;

  while(n!=0)    

    {    

         rem=n%10;      

         reverse=reverse*10+rem;    

         n/=10;   

    }

  cout<<reverse;

    return 0;

}


No comments:

Post a Comment

Post Top Ad

Your Ad Spot