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]
3 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]3 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
Putting commands in correct order so computers can read the commands
lana66690 [7]

Answer:

its b I think I'm pretty sure

8 0
2 years ago
Which answer choice correctly distinguishes among the three pieces of data?
wolverine [178]

Answer:

a. 1 is a packet, 2 is data, 3 is a frame.

Explanation:

And what is not  mentioned is segment which used TCP/UDP and is part of Transport layer. The packet carries the destination and sender IP address, and is part of the Network Layer. The frame has the Mac address of destination device and senders device and is part of data link layer.

Hence segment has no IP address, hence b. is not correct. Also, data cannot have the IP Address, and Frame has the MAC address, Hence, the above answer. And this arrangement is part of Data Encapsulation.

Also keep in mind data can be anything like a series of bits, or any and it can or not have a header.

7 0
2 years ago
1) Which forms are NOT appropriate to use for affirmations in Full Verbatim?
Oliga [24]

NOT appropriate to use for affirmations in Full Verbatim are :

d) Mm

e) Ammm

f) Aha

Explanation:

  • In verbatim transcription, interviews are transcribed word for word, and sound for sound.  Every um, uh, laugh, and sound must be recorded for posterity.

These are the preferred spellings of typical utterances:

  1. Affirmative: uh-huh, mm-hmm, yeah.
  2. Don't use: um-hum, um-hmm, uh-hum

  • Full verbatim refers to a transcript that includes absolutely everything that is said, exactly how the speakers say it. This means we include all ums, uhs, grammatical and vocabulary mistakes, false starts and repetitions - everything.
  • Verbatim is defined as an exact repetition without changing the words. An example of verbatim is when you quote someone exactly without changing anything.
3 0
3 years ago
An error occured trying to answer a question on brainly. What should I do?
nikdorinn [45]

You should probably retry answering it. Or two people are already answering it.

-Edge

7 0
3 years ago
Read 2 more answers
2. Create 4 riddleson keywords which is related to fire wall.​
Alona [7]

Answer:

It's been so good to have you as a friend:

2. As sweet and rich as honey-colored sun

3. Slanting steep across a summer lawn,

4. Gilding life with all that love can lend.

5. And now that you yourself have griefs to tend,

6. I want to be the strong and caring one

7. To count to you the lovely things you've done

8. Until these troubles pass and sorrows end.

9. You are so beautiful in form and soul

10. That you bring happiness to all you're near:

11. Just as a sea rose, flowering in mist,

12. Makes a paradise of some bleak shoal,

13. Turning truth to something far more clear,

14. No pain unsoothed or rain-swept cheek unkissed.

good~0~as_a_friend . good_to_have~Slanting~lawn .

It's_been~so_good~as_a_friend .

to_have~griefs_to~form_and_soul

Explanation:

7 0
3 years ago
Other questions:
  • Which toolbar is located next to the office button and contain the commonly used commands​
    15·1 answer
  • A user is experiencing slow performance with their computer. A technician suspects the computer has a virus and runs antivirus s
    12·1 answer
  • BIE, but plz help me on this ASAP!!! GIVING A BRAINLIEST... For this activity, imagine that you have been asked to teach a frien
    8·1 answer
  • U $ er Ideas for R 0 B 1 0 X?
    12·2 answers
  • What is the output of the following code:
    12·1 answer
  • Give an essay on a way I can be a better person. If not correct I will refund. Best answer gets brainiest. Detailed, 5 sentience
    10·2 answers
  • Explain how files can be identified as entities on the magnetic surface?
    8·1 answer
  • Write a user input program that simulates a game of a rolling pair of dice. You can create/simulate rolling one die by choosing
    10·1 answer
  • MmfbfMMMMMMMMMMMMMMMMMmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
    14·1 answer
  • In _________, the process requests permission to access and modify variables shared with others. a) entry section b) critical se
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!