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
lina2011 [118]
3 years ago
6

Write a program which increments from 0 to 20 and display results in Decimal on the console 2-b) Modify above program to increme

nt from 0 to 20 and display results in Binary on the console
Computers and Technology
1 answer:
SVEN [57.7K]3 years ago
3 0

Answer:

<em>This program is written in C++</em>

<em>Comment are used to explain difficult lines</em>

<em>The first program that prints 0 to 20 (in decimal) starts here</em>

#include<iostream>

int main()

{

//Print From 0 to 20

for(int i = 0;i<21;i++)

{

 std::cout<<i<<'\n';

}

}

<em>The modified program to print 0 to 20 in hexadecimal starts here</em>

#include<iostream>

using namespace std;

int main()

{

//Declare variables to use in conversion;

int tempvar, i=1,remain;

//Declare a char array of length 50 to hold result

char result[50];

//Print 0

cout<<"0"<<endl;

// Iterate from 1 to 20

for(int digit = 1; digit<21; digit++)

{

//Start Conversion Process

//Initialize tempvar to digit (1 to 20)

tempvar = digit;

while(tempvar!=0)

{

//Divide tempvar by 16 and get remainder

remain = tempvar%16;

if(remain<10)

{

 result[i++]=remain + 48;

}

else

{

 result[i++] = remain + 55;

}

//Get new value of tempvar by dividing it by 16

tempvar/=16;

}

//Print result

for(int l=i-1;l>0;l--)

{

cout<<result[l];

}

i=1;

cout<<endl;  

}

return 0;

}

//The Program Ends Here

See Attachments for program 1 and 2; program 2 is the modified version of 1

Download cpp
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> cpp </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> cpp </span>
You might be interested in
Computers help eliminate that repetitive of manual task. How can this benefit you in in your overall career
andrezito [222]

Continuing advances in technology and automation will be eliminating repetitive work in the offices of the future.

Computer technology has had a tremendous impact upon workers. In some instances, the introduction of computers has improved member working conditions, but, in others, new technology has produced several detrimental effects.

Explanation:

  • One of the key trends to emerge was that automation, smart machines and artificial intelligence will conduct repetitive work, replacing the need for people to complete these tasks.
  • Instead of worrying about job losses, executives should be helping to reduce jobs in which AI and machine learning take over boring tasks, while humans spend more time with higher-level tasks.

Here are three ways eliminating repetitive work can boost productivity:

  1. <u> Reduce Dependency on Email and Spreadsheets  :</u> Automation tools such as mobile applications, customized portals and project management tools eliminate the time spent checking and responding to emails and updating spreadsheets to reflect work progress. With automated tools, managers and their teams can post progress or project information on an integrated mobile app.
  2.  <u>Reduce Mistakes and Injuries  </u>: The possibility of human errors, which take more time to correct, is virtually eliminated when tasks are automated. Leaving the monotonous tasks to machines reduces the chance of injuries and allows workers to keep working on more strategic tasks.
  3. <u> Free Employees Time for High-Level Skills</u>  :  Many of the employees who spend their time undertaking repetitive tasks could actually be better utilized on more complex tasks.

There are a variety of illnesses that may be caused by repetitive computer work :

  • Tendonitis : pain and swelling of tendons at the junction between the tendon and its muscle;
  • Epicondylitis: pain and swelling where the tendons and bone join around the elbow joint, etc
3 0
3 years ago
Read 2 more answers
When reading words using a Scanner object's next method, _________. a. any characters at the beginning of the input that are con
zavuch27 [327]

Answer:

The answer is "Option d"

Explanation:

The scanner method is the full token of the process, that finds and returns. It is token, which is followed by both the inputs meeting and the guideline template. This method can block, even though the former instance of hasNext() is true while waiting for input, and wrong choices can be described as follows:

  • In option a, It is incorrect because the character at the beginning can't be considered.
  • In option b, It is wrong because the characters are known as the word in which blank space not a part of the word.
  • In option c, It is wrong because in this input before the call is not the method.
3 0
3 years ago
Write down the functions of network layer in your own words.ASAP pleaseeeeeee
Dima020 [189]

Answer:

The network layer is the layer is the layer 3 of the seven layer Open System Interconnect (OSI model) which functions as packet forwarder for the  intermediate routers  by implementing technologies used for switching that provides virtual circuits' logical path

The function of the network layer includes;

1) Routing and forwarding of packets to destination which enables connectionless communication

2) Enabling internetworking

3) Hierarchical host (IP) addressing

4) Sequencing of packets

5) Handling of errors

6) Control of network congestion to prevent the collapse of the network

Explanation:

7 0
3 years ago
Help with computer. homework
drek231 [11]
Im pretty sure the answer would be 82 because it's concatenating 2 to string(y)
8 0
3 years ago
Jabari is writing pseudocode for a new video game he wants to create. What should he include in his pseudocode?
erastova [34]

Answer:

The answer is "Option c".

Explanation:

The Pseudocode is a definition of actions in an algorithm or some other method of software engineering. It also uses regular programming language, formal conventions, and is associated with human learning rather than computer learning, and the wrong choice can be defined as follows:

  • In choice a, It is wrong because there are so many languages, and it is not easy to understand all.
  • In choice b, It is wrong because it is used for better understanding.
  • In choice d, it is wrong because words are also not only common to programmers.
5 0
3 years ago
Other questions:
  • Which description best describes how mass spectroscopy is useful in the field of forensic toxicology
    6·1 answer
  • What is constructive criticism?
    5·1 answer
  • Write a Python program stored in a file q1.py to play Rock-Paper-Scissors. In this game, two players count aloud to three, swing
    13·1 answer
  • Assslainsdffddsvvdesdssbhasasco5m
    5·2 answers
  • Hello i am indian eeee​
    10·1 answer
  • Which group scope can be used to assign permissions to resources only in the domain in which the group is created
    12·1 answer
  • Assume that the client wants to retrieve the www.cnn home page but has no information about the www.cnn web server IP address. D
    11·1 answer
  • Using the arrow key you can adjust the position of a selection in increments of
    7·1 answer
  • _____is used to organize and modify the properties of the current selection.
    6·1 answer
  • What are the five generations of computer software​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!