1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bagirrra123 [75]
3 years ago
10

Binary is a base-2 number system instead of the decimal (base-10) system we are familiar with. Write a recursive function PrintI

nBinary(int num) that prints the binary representation for a given integer. For example, calling PrintInBinary(5) would print 101. Your function may assume the integer parameter is non-negative. The recursive insight for this problem is to realize you can identify the least significant binary digit by using the modulus operator with value 2. For example, given the integer 35, mod by 2 tells you that the last binary digit must be 1 (i.e. this number is odd), and division by 2 gives you the remaining portion of the integer (17). What 's the right way to handle the remaining portion
Computers and Technology
1 answer:
Paladinen [302]3 years ago
7 0

Answer:

In C++:

int PrintInBinary(int num){

if (num == 0)  

 return 0;  

else

 return (num % 2 + 10 * PrintInBinary(num / 2));

}

Explanation:

This defines the PrintInBinary function

int PrintInBinary(int num){

This returns 0 is num is 0 or num has been reduced to 0

<em> if (num == 0)  </em>

<em>  return 0;  </em>

If otherwise, see below for further explanation

<em> else </em>

<em>  return (num % 2 + 10 * PrintInBinary(num / 2)); </em>

}

----------------------------------------------------------------------------------------

num % 2 + 10 * PrintInBinary(num / 2)

The above can be split into:

num % 2 and + 10 * PrintInBinary(num / 2)

Assume num is 35.

num % 2 = 1

10 * PrintInBinary(num / 2) => 10 * PrintInBinary(17)

17 will be passed to the function (recursively).

This process will continue until num is 0

You might be interested in
In Windows, which menu allows you to view file characteristics?
Zielflug [23.3K]
A. View Menu
Hope this helps!!! 
6 0
3 years ago
What is the relationship between data, information, business intelligence, and knowledge?
Tpy6a [65]

Answer:

The answer is below

Explanation:

Given the following:

Data is oftentimes described as actual truth or evidence about a situation or condition.

Information, on the other hand, is described as a refined data

Business Intelligence is defined as a combination of several information utilized in the decision-making process.

Knowledge is basically described as a form of intellectual properties, which encompasses a lot of experiences, skills, and creativity.

Therefore, the main relationship between all these is the utilization of these resources to enhance and improve the decision-making process. This is because, the gathered DATA is converted to INFORMATION, which in turn used to build BUSINESS INTELLIGENCE and finally, through the combination of past experiences, skills and talent, leads to a wealth of KNOWLEDGE to enhance and improve the decision-making process.

7 0
3 years ago
Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Els
kherson [118]

Answer:

// here is code in c.

#include <stdio.h>

// main function

int main()

{

// variable to store year

int year;

printf("enter year:");

// read the year

scanf("%d",&year);

// if year>=2101

if(year>=2101)

{

printf("Distant future");

}

//if year in 2001-2100

else if(year>=2001&&year<=2100)

{

   printf("21st century");

}

//if year in 19011-2000

else if(year>=1901&&year<=2000)

{

  printf("20th century");

}

// if year<=1900

else if(year<=1900)

{

  printf("Long ago");  

}

return 0;

}

Explanation:

Read the year from user.After this, check if year is greater or equal to 2101 then print "Distant future".If year is in between 2001-2100 then print "21st century".If year is in between 1901-2000 then print "20th century".Else if year is less or equal to 1900 then print "Long ago".

Output:

enter year:2018                                                                                                            

21st century

7 0
3 years ago
Read 2 more answers
Are the ways data represented and transmitted with computer law of nature or by law of man?
hammer [34]
Data representation is law of man.
5 0
3 years ago
Flight controllers make sure the facilitates that house mission control can operate properly, even in the event of a severe weat
Natalija [7]

Flight controllers making sure that they facilitate house mission control operating properly is True.

<h3>Who is a Flight controller?</h3>

This is an individual which forms part of the house mission control and they monitor and direct the movement of the aircraft in the skies and on the ground.

The functions mentioned above ensures that house mission control can operate properly, even in the event of a severe weather or national emergency.

Read more about Flight controller here brainly.com/question/1921832

7 0
2 years ago
Other questions:
  • Write a multithreaded program that generates the Fibonacci series using Pthreads thread library. This program should work as fol
    10·1 answer
  • What's the difference in unicode value between 'e' and 'a'? (consult a table of unicode values):?
    7·1 answer
  •   Why does a shaded-pole motor run at a constant speed?  A. The lines of force do not change direction.  B. The current through
    15·1 answer
  • Without a well-designed, accurate database, executives, managers, and others do not have access to the ____________________ they
    15·1 answer
  • A key tactic that is used in many attacks, but very frequently in CEO Fraud, is creating a sense of what?
    15·2 answers
  • Sensory cues are used for script writers to be able to get more creative with the story their are scripting for (i.e.
    15·1 answer
  • Write aemail to brother for laptop for vitrual classes​
    7·2 answers
  • I need help converting this to python but i have no idea how to.
    12·1 answer
  • Help ASAP please This is a skills lab simulation for college, it’s on Microsoft word is there a keyboard shortcut or something o
    12·1 answer
  • Type the correct answer in the box. Spell all words correctly. Which language should you use to add functionality to web pages?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!