answersLogoWhite

0


Best Answer

Identification Division.
Program-id. Example1.
Data Division.
Working-storage Section.
01 Num1 Pic 999 Value Zeros.
01 Num2 Pic 9 Value Zeros.
01 Num3 Pic 99 Value 10.
01 Result Pic 999 Value Zeros.
01 Temp Pic 99.
Procedure Division.
Calculator.
Display "enter First Number :".
Accept Num1.
Perform Until Num1 = 0
Divide Num1 By Num3 Giving Temp Remainder Num2
Compute Result =(result * Num3) + Num2
Compute Num1 = Num1 / Num3
End-perform
Display "result Is=", Result.
Stop Run.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

Use the following function to reverse a number:

unsigned reverse (unsigned num) {

unsigned accumulator=0;

while (num) {

accumulator *= 10;

accumulator += (num%10);

num /= 10;

}

return accumulator;

}

Note that if the number ends in 0 (no units), there will be no leading zero in the reversed number. To accommodate this, convert the number to a string then reverse the string. This is achieved by working from both ends of the string to the middle, swapping characters as we go:

void reverse_string (char* str) {

char *left, *right, temp;

unsigned len;

left = str;

right = str;

while (right) ++right; // traverse to null-terminator

len = (right-left)/2; // determine mid-point

while (len--) {

--right; // step back

// swap characters

temp=*left;

*left=*right;

*right=temp;

++left; // step forward

}

}

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Answer1 int a = 10, int b = 20; int temp; Solution: a=temp --->> Assings temp = 10 a=b --->> Assigns a= 20 b=temp --->> Assigns b=10

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program to find the reverse of a given number in COBOL?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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)


Why is COBOL a popular modern programming language used in business today?

COBOL is a business-oriented language that has a strong support for files, e.g., reading a file; performing any file operation is much simpler in COBOL than in other languages, such as C/C++. It has many built-in commands, e.g., edit-picture clause, redefines, rename facility, that are very useful for businesses.


What kind of jobs and employment does Cobol offer?

A worker with knowledge and experience of Cobol can find employment as a computer programmer. A job available to someone with more experience and a mastery of Cobol would be in maintaining mainframe computers.


Program to find reverse of given number using pointers?

#include #include void main() { int rev num=0; while(num>0) { rev num=rev num*10+num%10; num=num%10; } return rev_num; } int main(); { int num=4562; printf("reverse of number is%d",reverse digit(num)); getch(); return o; }


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

Related questions

Fox pro program to reverse the given number?

reverse programe in fox pro


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)


Second sem cobol question paper previous year?

Each question carries 10 marks. Explain the environment Division with example. Explain the Data Division with an example. Explain the various types of Move statements. Write a COBOL program to find a given integer is odd or even. An input file consists of the following Employee name, Employee number, Basic pay. Write a COBOL program to create an Indexed file which consists of Employee-name, Employee-number, Basic-pay and DA (DA = 25% of Basic-pay) Assume that an organisation has 20 departments. Each department has 5 stores. You are provided with total monthly sales of each stores for the month December 2000. Write a COBOL program to read the data, to write the sales report department wise and also write the total sales of the organisation.


Enter a number and draw a flow chart to get the reverse of the given number and the number is 435?

123


How can you generate a palindrome from a given number?

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


To write shell program to check the given number and its reverse are same?

echo "enter the number" if [ $# -ne 1 ] then echo "Usage: $0 number" echo " I will find reverse of given number" echo " For eg. $0 12321, I will print 12321" exit 1 fi n=$1 rev=0 sd=0 while [ $n -gt 0 ] do sd=`expr $n % 10` rev=`expr $rev \* 10 + $sd` n=`expr $n / 10` done echo "Reverse number is $rev"


What can the reverse lookup be used to find?

The reverse lookup is a telephone number data base. Instead of looking up a phone number based on a given name, a name can be looked up based on a given phone number. It is useful when receiving phone calls from an unknown phone number.


What kind of jobs and employment does Cobol offer?

A worker with knowledge and experience of Cobol can find employment as a computer programmer. A job available to someone with more experience and a mastery of Cobol would be in maintaining mainframe computers.


Why is COBOL a popular modern programming language used in business today?

COBOL is a business-oriented language that has a strong support for files, e.g., reading a file; performing any file operation is much simpler in COBOL than in other languages, such as C/C++. It has many built-in commands, e.g., edit-picture clause, redefines, rename facility, that are very useful for businesses.


Program to find reverse of given number using pointers?

#include #include void main() { int rev num=0; while(num>0) { rev num=rev num*10+num%10; num=num%10; } return rev_num; } int main(); { int num=4562; printf("reverse of number is%d",reverse digit(num)); getch(); return o; }


What name is given to prime numbers that you can reverse to make another prime number?

A mirror prime.


Do an 8086 assembler program to find parity of a given number?

sdfsdfsfsggbcvbg