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
A company wants to use online methods to target more customers. It decides to conduct a market research by collecting the data o
Ronch [10]

Answer:

They could use a CRM

A CRM tool lets you store customer and prospect contact information, identify sales opportunities, record service issues, and manage marketing campaigns, all in one central location — and make information about every customer interaction available to anyone at your company who might need it.

They Could Use PDC

The term “primary data” refers to data you collect yourself, rather than data you gather after another party initially recorded it. Primary data is information obtained directly from the source. You will be the first party to use this exact set of data.

They Could Use Quantitative vs. Qualitative Data

Quantitative data comes in the form of numbers, quantities and values. It describes things in concrete and easily measurable terms. Examples include the number of customers who bought a given product, the rating a customer gave a product out of five stars and the amount of time a visitor spent on your website.

Why Should I Track Users Data:

To ensure it's going smoothly, it's important to keep track of data that directly correlates to the potential success of your business. Key performance and financial metrics can help you address any problems with your business before they occur

8 0
3 years ago
One goal of networking is to:
malfutka [58]
To further your employment opportunities
8 0
3 years ago
Read 2 more answers
Kristine has been receiving many emails from a certain address. She thinks that these emails might harm her computer. Which acti
Paraphin [41]
Report the email adress then block them 
6 0
3 years ago
Read 2 more answers
I need help with doing a debate for ela. The debate topic is "do you think we are to dependable on our laptops/cellphones. My te
Mama L [17]

Answer:

I think we are so this is hard lol

Explanation:

we are not too dependable

things that show this is library are still open, school sports teams still flourish(if we were too depending on them they wouldnt) they help us plan ways to interact in person if we were too dependent businesses would struggle more and only be online

this is hard if I can think of any others I'll come back I'm sorry if this isn't any help

7 0
3 years ago
Read 2 more answers
And informative subject line is necessary for a good email true or false​
Yuki888 [10]

True.

A conscise and informative subject line is necessary for a good email. The subject line should give the receiver a good idea what the topic is of the email. An informative subject line also helps the recipient to identify the email as an important message and not spam.

7 0
3 years ago
Other questions:
  • 1. Write a program to prompt the user to enter a single character and respond back whether or not the character is valid dna. 2.
    12·1 answer
  • In terms of system thinking, what is process?
    15·2 answers
  • Advantages of e commerce
    14·1 answer
  • How do you implement instruction level parallelism
    11·1 answer
  • The __________ utility has the capability to manage users, create and administer user groups, and apply user rights to those use
    8·1 answer
  • Minerals that contain the elements silicon and oxygen are called ______.
    7·1 answer
  • How are special characters added to a Word document? Check all that apply.
    6·2 answers
  • 50 POINTS How do you express yourself and your creativity through computer science?
    12·1 answer
  • True or False(T or F): Point-and-shoot cameras have only 1 lens. *
    5·1 answer
  • A(n) ________ cloud does not free an organization from the issues associated with managing the cloud infrastructure, but it does
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!