Computer Science, asked by sonalibetageri7891, 1 year ago

Write an algorithm that allows a user to enter an integer valueof up to 5 digits and prints the reversed number?

Answers

Answered by RahulSingh111
0
This section covers various examples in Python programming Language. These Programs examples cover a wide range of programming areas in Computer Science. Every example program includes the problem description, problem solution, source code, program explanation and run time test cases. These examples range from simple Python programs to Mathematical functions, lists, strings, sets, dictionary, recursions, no-recursions, file handling, classes and objects. Here’s a listing of all the Python programs covering all these areas.
Answered by stefangonzalez246
0

Algorithm:

Reversed number

Input:  num

1) Initialize rev_num = 0

2) Loop while num > 0

      a) Multiply rev_num by 10 and add remainder of num divide by 10 to rev_num

           divide by 10 to rev_num

              rev_num = rev_num*10 + num%10;

          b) Divide num by 10

3) Return Rev_num

Example program in c

#include <stdio.h>

int reversDigits( int num)

{

int rev_num = 0;

while(num > 0)

{

Rev_num = rev_num*10 + num%10;

num = num/10;

}

return rev_num;

}

int main()

{

int num = 85423;

printf("Reverse of no is %d", reversDigits(num));

getchar();

return 0;

}

OUTPUT:

Reverse of no is 32458

To Learn More...

brainly.in/question/2274110

brainly.in/question/5932806

Similar questions