fork(1) download
  1. #include<stdio.h>
  2.  
  3. int main(){
  4. int n, i, j, bin_rev=0,bin=0;
  5. printf("Enter a number to convert : ");
  6. scanf("%d",&n);
  7.  
  8. /*****************************/
  9. i=1;
  10. while(n){
  11. bin_rev=bin_rev+(n%2)*i;
  12. i=i*10;
  13. n=n/2;
  14. }
  15.  
  16. i=1;
  17. while(bin_rev){
  18. bin=bin+(bin_rev%10)*i;
  19. i=i*10;
  20. bin_rev=bin_rev/10;
  21. }
  22. /*****************************/
  23.  
  24. printf("\nBinary is %d",bin);
  25.  
  26. getch();
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:26:6: warning: implicit declaration of function 'getch' is invalid in C99 [-Wimplicit-function-declaration]
     getch();
     ^
prog.c:4:16: warning: unused variable 'j' [-Wunused-variable]
     int n, i, j, bin_rev=0,bin=0;
               ^
2 warnings generated.
/home/fGWGh4/prog-b38c8a.o: In function `main':
prog.c:(.text+0xc1): undefined reference to `getch'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
stdout
Standard output is empty