answersLogoWhite

0

You can reverse a number by extracting its digits (num%10) and then appending these digits to a new variable. Here is the code:

int num, revnum = 0, temp;//revnum stored the reversed number

scanf("%d", &num);//The number to be reversed

temp = num;

while( temp != 0){

revnum = revnum*10 + temp%10;

temp /= 10;

}

printf("The reversed number is :%d\n", revnum);

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is the use of Reverse String in C program?

The use of the reverse string in C program is used to reverse the letters in the string. An example would be reverse me would be reversed to em esrever.


How do you Write a C program to reverse an Integer number.?

Reference:cprogramming-bd.com/c_page2.aspx# reverse number


How you write a program in c plus plus to print plaindromic numbers from 1 to n?

To check if a number is a palindrome, reverse the number and see if it is equal to the original number. If so, the number is a palindrome, otherwise it is not. To reverse a number, use the following function: int reverse(int num, int base=10) { int reverse=0; while( num ) { reverse*=base; reverse+=num%base; num/=base; } return(reverse); }


How do you convert a number that consist of alphabet and number in reverse order?

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); }


Reverse of a number in c?

You can get the answer in the following link : http://www.dreamincode.net/forums/showtopic27453.htm


How do you know that a numeric is palindrome or not using c or pascal language?

Reverse the digits then check of the new number is the same as the original number.


Does a c-130 have speedbrakes?

The C-130 does not have a speed brake. They use a combination of brakes, flaps, and reverse thrust to slow down.


How do you make a programme in c language to get the reverse of any printed numberusing while loop or if conditional statement?

//Reverse of the Number // Programme Written By Maulin Thaker Ahmedabad; #include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e; clrscr(); printf("Enter the Number to Find it's Reverse\n"); scanf("%d",&a); while(a!=0) { b=a%10; c=a/10; printf("%d",b); a=c; } getch(); }


How do you make a program to reverse nummber in c language?

I'd use sprintf (assuming the number wasn't a string already) and pointers. If that's not enough of a clue, you're really not ready to be in this programming class.


Write a C program to reverse the digits of a number?

/*Reverse the digits of a number,Gankidi*/ #include<stdio.h> void main(void) { int num,sum=0,i,rem; printf("Enter a number"); scanf("%d",&num); while(num>0) { rem=num%10; num=num/10; sum=sum+(rem*10); } printf("the reverse number is %d",sum); }


C program to check whether the number and its reverse are same or not?

#include <stdio.h> #include<conio.h> void main () { int a,r,n,sum=0; clrscr(); printf("enter the number"); scanf("%d",& n); c=n while (n!=0) { a=n%10; n=n/10; sum=sum*a+a } printf("the reverse is %d \n",sum); if(c==sum) printf("\n the given number is palindrome"); else printf("\n the given number is not a palindrome"); getch(); }


Why does the 1089 maths trick work?

let a, b, c denote the three digits of the original number, then the three-digit number is 100a+10b+c. The reverse is 100c+10b+a. Subtract: (100a+10b+c)-(100c+10b+a) to get 99(a-c). Since the digits were decreasing, (a-c) is at least 2 and no greater than 9, so the result must be one of 198, 297, 396, 495, 594, 693, 792, or 891. When you add any one of those numbers to the reverse of itself, you get 1089