Question: Help ASAP! My c program code is supposed to work with one function only. Its supposed to have the user enter an integer below 10,

Help ASAP!

My c program code is supposed to work with one function only. Its supposed to have the user enter an integer below 10, and the program will print out the binary number in reversed.

I can't figure out how to get the program to run under the under the void reverse(int number) function, and without using int main() to display the output. It should be a function parameter.

The code with the main() function is in another file that will call the function call for the reverse bit operation, passing the integer operand as a parameter to my function, so I cannot have two mains in my project....or I the program will get an error.

code is below:

#include #include

void reverse(int number) { int total_bits = sizeof(number) * 8; int reverse_number = 0; int i; for (i = 0; i < total_bits; i++) { if((number & (1 << i))) reverse_number |= 1 << ((total_bits - 1) - i); } } int num; printf("Type a integer less than 10: "); scanf("%u", &num); if ( number < 10) { printf("%u", reverse_number(number)) } else { printf("error"); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!