SabirSazzad

Reverse Function

Mar 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <stack>
  4. #include <stdlib.h>
  5. #include <algorithm>
  6. #include <vector>
  7. using namespace std;
  8.  
  9. int reverse(int num)
  10. {
  11.     int temp = num;
  12.     int sum = 0;
  13.     while (temp)
  14.     {
  15.         sum*=10;
  16.         sum += temp%10;
  17.         temp/=10;
  18.     }
  19.     return sum;
  20. };
  21.  
  22. int main()
  23. {
  24.     int y,x = 05;
  25.     y = reverse(x);
  26.     cout << y;
  27.  
  28.     return 0;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment