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
Nesterboy [21]
4 years ago
9

Create a program in c/c++ which accepts user input of a decimal number in the range of 1 -100. Each binary bit of this number wi

ll represent the ON/OFF state of a toggle switch.
Computers and Technology
1 answer:
kirill115 [55]4 years ago
8 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

void switch_fun(int input)

{

//array to store binary of input number

   int bin[7];

   // convert the number into binary

   for(int i=0; input>0; i++)

       {

           bin[i]=input%2;

           input= input/2;

       }

   // print the switch number and their status

   cout<<"Switch number:\t 1\t 2\t 3\t 4\t 5\t 6\t 7 \n";

   cout<<"status:      ";

   for(int j=6;j>=0;j--)

   {

   // if bit is 1 print "ON" else print "OFF"

       if(bin[j]==1)

           cout<<"\t ON";

       else

           cout<<"\t OFF";

   }

}

int main()

{

   int n;

   cout<<"enter the number between 1-100 only:");

   // read a number in decimal

   cin>>n

   // validate the input

   while(n<1 ||n>100)

   {

     cout<<"wrong input!! Input must be in between 1-100:"<<endl;

     cout<<"enter the number again :";

     cin>>n;

   }

// call the function with input parameter

  switch_fun(n);

return 0;

}

Explanation:

Read a decimal number from user. If the number is not between 1 to 100 the it will again ask user to enter the number until the input is in between 1-100.Then it will call the fun() with parameter n. First it will convert the decimal to binary array of size 7.Then print the status of switch.If bit is 1 then print "ON" else it will print "OFF".

Output:

enter the number between 1-100 only:-5

wrong input!! Input must be in between 1-100:

enter the number again :125

wrong input!! Input must be in between 1-100:

enter the number again :45

Switch number:   1       2       3       4       5       6       7

Status:          OFF     ON      OFF     ON      ON      OFF     ON

You might be interested in
Consider the operation of deleting the root of a binary search tree. if the root has one child, then ________.
PSYCHO15rus [73]

The reference to the root of the tree should be set to null

<h3>Can the root of a binary tree be null?</h3>
  • Only the subtrees are nulled out, the root always remains and will never be set to null.
<h3>What is null root?</h3>
  • null-, root. -null- comes from Latin, where it has the meaning "none; not one.
  • '' This meaning is found in such words as: annul, null, nullify.

To learn more about it, refer

to brainly.com/question/24448358

#SPJ4

4 0
2 years ago
What company was affected by the cloudbleed vulnerability?
DIA [1.3K]

The <em>cloud bleed vuneraliblity</em> describes the security flaw which was discovered in 2017 and had affected internet service company CloudFlare and many websites using the company's services.

CloudFlare is a internet service company which operates to provide security of data to millions of websites. However, a glitch occured during a certain security update which led to a loophole which wasn't discovered for months.

This made the user data on CloudFlare's network susceptible over the course of that period. It was reported that companies such as Uber, OKcupid and several others on the CloudFlare security network were affected.

Therefore, the company affected by the cloud bleed vuneraliblity is CloudFlare.

Learn more :brainly.com/question/25018707

7 0
3 years ago
Write a method, makeSubjectLine, that gets a String argument and returns the same String but with "Subject: " in front of it. So
Anna [14]

Answer:

public class newass {

   /*

   Write a method, makeSubjectLine, that gets a String argument and returns the same String but with "Subject: " in front

   of it. So if the argument is "Are you going to the show?" the method returns "Subject: Are you going to the show?".

    */

   public static void main(String[] args) {

       System.out.println(makeSubjectLine("Are you going to the show?"));

   }

   public static String makeSubjectLine(String subj){

       return "Subject: "+subj;

   }

}

Explanation:

The solution in Java Programming Language

6 0
3 years ago
Of all the database types we have studied, which database seems most appropriate for a startup building a new note-taking app fo
Deffense [45]

Answer:

<u>documents database</u>

Explanation:

This database is most appropriate because we need to remember that a <u>note-taking app</u> would not necessarily need too many functions apart from the basics text input operations.

Also, we need to note that the digital infrastructure required to build a documents database, is very convenient for a startup because they may have lesser resources.

7 0
3 years ago
Read 2 more answers
. simulation programs can use a range of integer values to mimic variability in the simulation. a. true b. false
RSB [31]

True, simulation programs can use a range of integer values to mimic variability in the simulation.

What are simulation programs ?

The foundation of simulation software is the process of simulating a genuine phenomena using a set of mathematical equations. In essence, it's a program that enables the user to simulate a process while still observing it in action.
It is theoretically possible to simulate on a computer any phenomenon that can be reduced to numerical values and equations.
Identifying the most crucial elements that have an impact on the simulation's objectives is one of the tricks to creating useful simulations.

Therefore, simulation programs can use a range of integer values to mimic variability in the simulation.

You can learn more about simulation programs from the given link:

brainly.com/question/27159343

#SPJ4

5 0
2 years ago
Other questions:
  • kelly wants to buy a new operating system for a laptop. under which category will it be in online store?
    5·1 answer
  • Write in general about ergonomic injuries and also mention the symptoms that computer users exhibit when they experience these s
    11·2 answers
  • Which of the following correctly describes the reason for quality customer service?
    15·2 answers
  • What does the hexadecimal number 2D represent in the binary system?
    9·1 answer
  • 13) Search engines and metasearch engines are examples of which network application?
    12·1 answer
  • Pierre received an urgent email appearing to come from his boss asking him to respond quickly to the email with the company cred
    10·1 answer
  • The variable most_recent_novel is associated with a dictionary that maps the names of novelists to their most recently published
    12·1 answer
  • When does MMF2 inactivate an Active object? A. When the score is higher than the game's previous high score B. When the player d
    15·1 answer
  • What is bespoke software???​
    9·2 answers
  • What types of character Microsoft Excel understand​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!