Reverse A Number In C & C++

preview_player
Показать описание
JOIN ME
—————

COMPLETE PLAYLIST
————————————

INTERVIEW PLAYLIST
————————————

QUICK SHORT VIDEOS
————————————-

In this video we will learn how to reverse some integer number, before this video we learned how to reverse and array of string.
We will use module operator for extracting single numbers from the given number then keep dividing that number and then and keep adding the extracted number to a new number and like this in the end we will have the reversed number.

#reversenumber #programmingInterviewQuestions #numbers
Рекомендации по теме
Комментарии
Автор

REVERSE NUMBER WITHOUT SWAP FUNCTION

#include<bits/stdc++.h>
using namespace std;
int rev(int digit)
{
int reverse_number=0;
int remainder=0;
while(digit!=0)
{
remainder=digit%10;
+ remainder;
digit=digit/10;
}
cout<<reverse_number;
}
int main()
{
int digit;
cin>>digit;
rev(digit);
}

AmitKumar-tpfv
Автор

You can also use atoi() then reverse the string and vice versa.

fuadcs
Автор

bro thats so big brain holy shit <3 <3 <3

nikIsOnlyOne
Автор

#include<bits/stdc++.h>
using namespace std;
int rev(int arr[], int n)
{
int i=0;
int j=n-1;
while(i<j)
{
swap(arr[i], arr[j]);
j--;
i++;
}
for(int i=0;i<n;i++)
{
cout<<arr[i];
}

}
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
rev(arr, n);
}

AmitKumar-tpfv
Автор

Sir for this 1073741323 number it's not working once u try and let me know it'll works or not

fridaynightfirstshow