CS103 HW 3-152 (1) patibility Mod Word FILE HOME NSERT DESIGN PAGE LAYOUT REFERE
ID: 3680110 • Letter: C
Question
CS103 HW 3-152 (1) patibility Mod Word FILE HOME NSERT DESIGN PAGE LAYOUT REFERENCES MAILINGS REVIEW VIEW redha yasser Find Calibri (Body 11 A A Aa A EE EE 'ai EEE AaBbCcD AaBbccDd AaBb C AaBbccDd AaBbCCDd Copy Replace Paste No Spac... Heading 1 Heading 2 Heading 7 Subtitle subtle Em... Emphasis Select Heading 6 1 Normal Title B I U 1 Format Painter Paragraph Fon Question 01: Write down a program that converts decimal number to binary number and displays the reverse of the result e.g., binary number of 10 is 1010; your program should produce/display as 0101. Your program should ask user for a decimal number to be input and then it will display the reverse of the binary number for the input value. Few sample input and output screens are provided her Enter an integer number: 100 Enter an integer number:500 0010011. 001011111. Enter an integer number 24 Enter an integer number: 10 0101 Ed Ed PAGE 1 OF 3 482 WORDS LK ENGLISH (UNITED KINGDOM) 180 96 ENG 09:32 uoExplanation / Answer
#include<stdio.h>
int main(){
long int m,num=0,a=1;
int n,rem,s;
printf("Enter any decimal number->");
scanf("%d",&n);
m=n;
while(n!=0){
rem=n%2;
num=num+rem*a;
n=n/2;
a=a*10;
}
printf("The value %ld in binary is-> ", m);
printf("%ld",num);
while(num > 0)
{
s = s*10;
s = s + (num%10);
num = num / 10;
}
printf(" Reverse of number is: %d",s);
return 0;
}