answersLogoWhite

0

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

Updated: 8/17/2019
User Avatar

Wiki User

12y ago

Best Answer

/*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);

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C program to reverse the digits of a number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can you generate a palindrome from a given number?

You write the number and then follow it with the digits in reverse order.


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

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


Write a Shell program to find the sum of cube of individual digits of a number?

no thanks


How do you write a C program to reverse the 3 digits of a number using while loop?

unsigned reverse (unsigned num) { unsigned rev = 0; while (num) { rev *= 10; rev += num % 10; num /= 10; } return rev; }


How do you write a program that outputs a given characters in reverse?

write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


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.


Write a program to find the number of digits in the number?

#include &lt;stdio.h&gt; int main(int argc, char **argv) { if (argc&lt;1) { printf("Usage: %s number\n",argv[0]); return -1; } int digits=1, i=atoi(argv[1]); while (i/=10) ++digits; printf("%d\n",digits); }


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 write 95billion32million659thousands4?

To write the number in digits, you would write it like this: 95,032,659,004.


What number is 8.4 million Write the number out with digits?

8,400,000.00


Write a program to read your name and reverse it using arrays?

abdulrahman