Reverse of a 32 bit unsigned integer given in a coding test(with hidden test cases) | Sololearn: Learn to code for FREE!
- 1

# Reverse of a 32 bit unsigned integer given in a coding test(with hidden test cases)

You will be given variable list of unknown length, containing 32-bits unsigned integers. You are required to give as output a comma separated list, showing for each element in the list the integer you get by reversing bits in its binary representation. For example, if the list is 32768, 101200 and 262144, you are expected to give as output 65536, 181501952 and 8192. Integers in the list will be given one per line.

16th May 2020, 5:46 PM
Ashwin Goutham G
8 ответов
+ 6
Ashwin Goutham G Don't ask for code directly. Show your attempts first.
16th May 2020, 5:59 PM
A͢J
+ 2
Here's the working code in Java, this will Help!! import java.util.*; public class Convert{ public static void main(String []args){ Scanner sc=new Scanner(System.in); int input; String separator=""; while(sc.hasNextInt()) { input=sc.nextInt(); System.out.print(separator+Integer.reverse(input)); separator=", "; } } }
3rd May 2021, 4:42 AM
Shabaz
0
#include <stdio.h> #include <math.h> int main() { unsigned int i,n, in[10], z[10],rem, rev=0; printf("Enter the value of n\n"); scanf("%d",&n); printf("Enter the input values\n"); for(i=0;i<n;i++) { scanf("%u",&in[i]); } for(i=0;i<n;i++) { while(in[i]!=0) { rem=in[i] % 10; rev=rev*10 +rem; in[i]=in[i]/10; z[i]=rev; } } for(i=0;i<n;i++) { printf("%u",z[i]); } return(0); }
17th May 2020, 9:38 AM
Ashwin Goutham G
17th May 2020, 10:12 AM
A͢J
- 1
This is the kind of result I want Case 1: For the input provided as follows: 32768 101200 262144 Output of the program will be 65536, 181501952, 8192
14th Mar 2021, 7:17 AM
chandan nath
- 4
This is not the solution but just an attempt
17th May 2020, 9:39 AM
Ashwin Goutham G
- 4
I want to reverse the number's binary form but don't know how to do
17th May 2020, 9:40 AM
Ashwin Goutham G
- 4
This is the kind of result I want Case 1: For the input provided as follows: 32768 101200 262144 Output of the program will be 65536, 181501952, 8192
17th May 2020, 9:42 AM
Ashwin Goutham G
Актуальное сегодня
Hi I am new