answersLogoWhite

0


Best Answer

To reverse a number, first convert the number to a string, then reverse the string. Given your number consists of alphanumeric characters, the number must already be a string so simply reverse the string:

#include<string>

using std::string;

string reverse (const string& s) {

string str {};

for (auto c : s) str.insert (str.begin(), c);

return str;

}

int main () {

std::cout << "Enter a number: ";

string s {};

std::cin >> s;

std::cout << "The number in reverse is: " << reverse (s);

}

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you convert a number that consist of alphabet and number in reverse order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you convert 35 into 53 using bitwise operators?

22 XOR 35 = 53Note that the value 22 is a magic number because it only works for the values 35 and 53. The value 22 was calculated as follows:35 XOR 53 = 22It can also be seen that:22 XOR 53 = 35It is assumed that you are actually looking for some bitwise operation that will reverse the digits in any number. You cannot do this because in order to determine the magic number for any given value, you first need to XOR the value with the reverse of the value, which means you must already know the reverse of the value.To reverse any value that is not a multiple of 10, use the following function:unsigned reverse (unsigned num) {unsigned rev;rev = 0;while (num) {rev *= 10;rev += num % 10;num /= 10;}return rev;}Note that reverse(10) is 1, not 01. If you want to convert trailing zeroes into leading zeroes, convert the number to a string and then reverse the string, returning the string rather than the numeric value.


Program for print reverse string of given number in java?

public class StringReverseExample { public static void main(String[] args) { int num=1001; int n=num, rev; while(num!=0) { int d=num%10; rev= (rev*10)+d; num=num/10; } System.uot.println(rev); } }


Write a program to find the reverse of a given number with help of function?

//Reverse of the Number #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int main () { int num,mod,rev=0; printf("Enter a number:"); scanf("%d", &amp;num); while (num&gt;0) { mod=num%10; rev=(rev*10)+mod; num=num/10; } printf("Reverse of the given number: %d", rev); getchar(); return 0; } // alternative solution based on reversing the alphanumeric representation of // the number: void rev(int me) { char alpha[32]; sprintf(alpha, "%d", me); for (const char* cp = alpha + strlen(alpha) - 1; cp &gt;= alpha; --cp) { putchar(cp); } }


Algorithm to convert a number representing radix r1 to r2?

algorithm to convert a number representing radix r1 to radix r2


Wap to calculate reverse of a number without loops?

Main(include.h)

Related questions

WHAT NUMBER IS I IN THE ALPHABET?

in the English alphabet it is number 9


Number of centimeters in a meter?

To convert centimeters to meters, multiply by 0.01


The difference between the alphabet key and the number key?

alphabet keys type letters and number keys type number alphabet keys:qwertyuiopasdfghjklzxcvbnm number keys:1234567890


What number is the letter w in the alphabet?

W is letter number 23 in the alphabet.


What number is I and M in the alphabet?

'I' is the 9th letter in the alphabet.'M' is the 13th letter in the alphabet.? ? ?


What letter comes after 23 in the alphabet?

23 is not in the alphabet. It is a number. The next number is 24. If you are asking what the 24th letter of the alphabet is, it's X.


What number is m in alphabet?

M is the thirteenth letter in the alphabet.


What number of the alphabet is n?

It is the fourteenth letter of the English alphabet.


How to write a program in python to print the reverse of a number?

In python, type the following into a document. NOTE: Sentences following a # symbol are comments, and are not necessary for the program to run. #!/usr/bin/python #This program takes a input from a user and reverses it. number = input("Type a number: ") #This takes input from a user. a = len(number) #This finds the length of the number reverse = "" #This sets the variable reverse to an empty string. for i in number: a = a-1 #The places in a string start from 0. The last value will be the length minus 1.reverse = reverse + number[a] #Makes the number's last digit the new string's first. print("The reverse of", number, "is", reverse + ".") #prints the resulting string. This program will take any sequence of characters and reverse them. The final value is a string, but if an integer is needed, one needs only to add the line reverse = int(reverse) above the print statement. However, this will stop the program from being able to reverse strings, as it is not possible to convert a string to an integer if it is not a number.


What is the word for the number 4 in the greek alphabet?

The word for the number 4 in the Greek alphabet is &quot;tetra.&quot;


How do you convert 2013 to a base 5 number?

Repeatedly divide by 5 (noting the remainders) until the quotient is zero. Then write the remainders out in reverse order.


Can you use a sentence with the word alphabet?

There's a number in my alphabet soup!