Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ reverse integer

#include <iostream>
using namespace std;
 
int main()
{
    int num;
    
    //Input a number
    cout << "Enter a Number: ";
    cin >> num;
    
    //Initialize rev with 0
    int rev=0;
    
    //Append digits in reverse order
    while(num>0){
        rev = rev*10 + num%10;
        num = num/10;
    }
    
    cout << "Reverse: " << rev;
    return 0;
}
Comment

reverse c++

reverse(str.begin(),str.end());
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ call by value vs call by reference 
Cpp :: c++ type casting 
Cpp :: scan line in c++ 
Cpp :: switch case c++ 
Cpp :: check if file is empty c++ 
Cpp :: c++ cin operator 
Cpp :: c++ pointer null vs nullptr 
Cpp :: rand c++ 
Cpp :: c++ char it is a number 
Cpp :: height of bst cpp 
Cpp :: abs in c++ 
Cpp :: print each number of digit c++ 
Cpp :: for loop in c++ 
Cpp :: how to take space separated input in c++ 
Cpp :: why are inline keyword in header c++ 
Cpp :: clear the input buffer in cpp 
Cpp :: c++ read each char of string 
Cpp :: comparator for priority queue c++ 
Cpp :: functors in c++ 
Cpp :: how to sort a string alphabetically in c++ 
Cpp :: c++ pause linux 
Cpp :: how to reverse a vector 
Cpp :: print octal number in c++ 
Cpp :: push local branch to another remote branch 
Cpp :: c++ min int 
Cpp :: length of string in c++ 
Cpp :: C++ fill string with random uppercase letters 
Cpp :: c++ string split 
Cpp :: c++ hash combine 
Cpp :: quicksort geeksforgeeks 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =