You need to write a C program that accepts an integer as input and displays the binary equivalent of an integer. The C program uses a recursive function, called binary_convert, to do the binary conversion. Binary notation represents numbers in terms of powers of two and uses only the digits 0 and 1.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

You need to write a C program that accepts an integer as input and displays the binary equivalent of an integer. The C program uses a recursive function, called binary_convert, to do the binary conversion. Binary notation represents numbers in terms of powers of two and uses only the digits 0 and 1.

The initial start is given below:

 
#include <stdio.h>

/*line 1 */

int main(void)
{
    int num;
    
 
    printf("Enter a number: ");
    /*line 2 */
    /*line 3 */
    
    return 0;
}

/*line 4 */
{
 
    int rem, div; 
    
    /*line 5 */
    { 
        /*line 6 */   
        /*line 7 */
    }
         
    /*line 8 */
        
    /*line  9*/
    /*line 10 */
}
                                                                                                                                                                                    
/* line 1 */
                                                                                                                                                                                    
/*line 2 */
                                                                                                                                                                                    

/*line 3 */

                                                                                                                                                                                    

/*line 4 */

                                                                                                                                                                                    

/*line 5 */

                                                                                                                                                                                    

/*line 6 */

                                                                                                                                                                                    

/*line 7 */

                                                                                                                                                                                    
/*line 8 */
   
   
                                                                                                                                                                                    
/*line 9 */
 
                                                                                                                                                                                    

/*line 10 */

1.
void   binary_convert ( int   num )
2.
binary_convert(rem); 
3.
  printf ( "%d" ,   num );
4.

#include <math.h>

5.
binary_convert(div);
6.
if (num > 1)
7.
scanf ( "%d" ,  & num );
8.
binary_convert ( num );
9.
if   ( num  <=  1 )
10.
div = num/2; rem = num%2;
11.
scanf("%s", &num);
12.
return 0;
13.
printf("%d", rem);
14.
return;
15.

 

void binary_convert(int num);
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY