answersLogoWhite

0

#include <iostream>

#include <time.h>

unsigned int reverse( unsigned int num )

{ const unsigned int base=10;

unsigned int rev=0;

while( num )

{rev*=base;rev+=num%base;num=num/base;}

return( rev );

}

int main ()

{ srand(( unsigned ) time( NULL ));

// Print 10 random numbers in reverse.

for( int i=0; i<10; ++i )

{unsigned int r = ( unsigned int ) rand();std::cout << r << " = " << reverse(r) << std::endl;}

return(0);

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you print size of integer?

the size of an integer is determaind by using the function "sizeof(c)",here 'c' is any integer.


Write a FORTRAN code to calculating factorials?

Here is a simple FORTRAN code to calculate the factorial of a given non-negative integer: program factorial implicit none integer :: n, result print *, &quot;Enter a non-negative integer:&quot; read *, n result = 1 if (n &lt; 0) then print *, &quot;Factorial is not defined for negative numbers.&quot; else do i = 1, n result = result * i end do print *, &quot;Factorial of&quot;, n, &quot;is&quot;, result end if end program factorial This program prompts the user for an integer, checks if it's non-negative, and then calculates the factorial using a loop.


To print the multiples of a given number using loops in c?

Yes, it is possible to do that.


Writing a program which prints a text of 4 lines consisting of characters integer values and floating point values using print statement?

To write a program that prints a text of 4 lines consisting of integer and floating point values, you can use formatted strings in Python. Here's a simple example: int_value = 42 float_value = 3.14 print(&quot;Line 1: Integer value is&quot;, int_value) print(&quot;Line 2: Float value is&quot;, float_value) print(&quot;Line 3: Sum of values is&quot;, int_value + float_value) print(&quot;Line 4: Float value to two decimals is {:.2f}&quot;.format(float_value)) This code snippet prints four lines, showcasing both integer and floating point values.


How can you print some numbers in different column in Fortran 90?

In Fortran 90, you can print numbers in different columns using formatted output with the PRINT or WRITE statements. You can specify the format using format descriptors such as F for floating-point or I for integers, followed by the desired width. For example, PRINT '(I5, F10.2, I5)', num1, num2, num3 will print num1 as an integer in a width of 5, num2 as a floating-point number with 2 decimal places in a width of 10, and num3 as another integer in a width of 5. Adjust the format specifiers as needed to align the output in columns.


How to print the reverse of an array without using backward loop?

int youArray[arraysize] = {...};...for (int i = 1; i


How do you explain how an integer can be represented using BCD?

Explain how an integer can be represented using BCD?


By using awk programming how to count number of lines in a given file without wc command?

Use the following:awk 'END { print NR }'Awk will count the lines and print it out.


What are some websites offering a reverse DNS lookup service?

In computer networking, reverse DNS lookup or reverse DNS resolution is the determination of a domain name that is associated with given IP adress using DNS of the internet.


How do you print square using for loops?

how to print "square" using for loop


How many true conditional statements may be written using the following statements n is a rational number n is a integer n is a whole number?

Given that an integer is the same as a whole number, there are four true conditional statements.


How do you convert integers in character using c?

In C, an integer and a character are the same thing, just represented differently. For example: int x = 65; printf("x = (int) %d, (char) %c\n", x, x) should print "x = (int) 65, (char) A" You can also use the atoi (ascii to integer) and itoa (integer to ascii) functions.