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

Answers

Answer 1
Answer:

Answer:

This program is written in C++

Comment are used to explain difficult lines

The first program that prints 0 to 20 (in decimal) starts here

#include<iostream>

int main()

{

//Print From 0 to 20

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

{

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

}

}

The modified program to print 0 to 20 in hexadecimal starts here

#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


Related Questions

A _____ area network is one step up from a _____ area network in geographical range.
A teacher at your school is using her district issued laptop to create spreadsheets for her part-time job as a bookkeeper. Which standard, if any, is this teacher violating?
Which option did you choose? Boxing? A different sport? Why did you choose it
The users, groups, logins, and roles that have access to a server are called ________________. a. ids b. permissions c. principals d. securables
In ____________, a large address block could be divided into several contiguous groups and each group be assigned to smaller networks.

The market is in
until the price of goods reflects equal supply and demand.

Answers

Supply and demand us an economic model of price determination in a market if demand increses and supply remains unchanged then it leads to higher equalibrium price and higher quantity if demand decreases s and supply remains unchanged then it lead to lower equilibrium price and lower quantity hope this helps XD

A majority of the people whose information was compromised are homeless; therefore there is no easy way to contact them in order to alert them of the security breach. How should Data-Time Inc. manage this breach in security

Answers

Incomplete question. Here's the full question:

Data-Time Inc. is a company that manages databases for a large city in Colorado. Included in these databases is information collected from the city’s homeless shelters and free clinics. Specifically, the databases contain personal information of the users of these services over the past 10 years; this includes people’s Social Security numbers and health records.

This data is highly secure and only accessible to the employees of Data-Time Inc. Employees are given a laptop when they are hired which allows them to access the database remotely. Unfortunately, one of these laptops is stolen and the security of the database is compromised.

A majority of the people whose information was compromised are homeless; therefore there is no easy way to contact them in order to alert them of the security breach. How should Data-Time Inc. manage this breach in security?

Explanation:

Since the emphasis is not on reversing the breach that has occurred, but on managing the level of security damage that could occur, it is important measures are directed towards preventing unauthorized access to sensitive information.

For example, the Media Access Control Address (MAC address) of the laptop if known could be greylisted from accessing the server that contains the sensitive information.

Define a forest root domain.

Answers

Answer: Forest root domain is used in the Active Directory forest for the first domain section.A domain is defined as the cluster of databases. This domains has Schema Admin groups and  Admin of enterprise.

Forest is defined as the boundaries inside which the accessing of the network can be done by the clients. Root is the section that is at the highest level in the complete domain name system.The combination of these two section form the forest root domain system.

Express 278910 in binary – Use the technique of subtracting powers of 2

Answers

Answer: The decimal number 278910, expressed in binary, is as follows:

               1000100000101111110

Explanation:

Any decimal number can be expressed as a linear combination of powers of 2, as follows:

N = aₙ* 2ⁿ +.....+ a₀*2⁰, where the coefficients aₓ can be 0 or 1.

This means that any number, can be decomposed in powers of 2, so a useful and at the same time simple way to find the binary equivalent of a decimal number, is simply to substract from the number the maximum power of 2 that gives a positive outcome, and put a "1" in the most left position, filling with zeros to the right till finding the following power of two (obtained repeating the process with the result from the first substraction).

For the first substraction, we try different choices, until we get a positive result substracting 2¹⁸ from 278910, as follows:

278,910-262,144= 16,766.

Intuitively, we know that as being 16 a power of 2, it's possible that a number close to the one we have as a result, be a power of 2 indeed.

Trying with 2¹⁴, we find that we are right, because the result is a small number:  

16,766 - 16,384 = 382

Now. it's very easy, as the greatest power of 2 smaller than 382, is 2⁸=256.  

382-256= 126.

126 can be written as 64+32+16+8+4+2, so all that we need now is, going from left to right, put "1", as the coefficient of the powers of 2 18, 14, 8, 6, 5,4,3,2 and 1, filling with zeros the remaining ones.

The final number can be written as follows:

1000100000101111110

Gabby needs to perform regular computer maintenace . whats should she do

Answers

Answer:

The correct answers are A,C,D,E or Remove unwanted files, Back up her data. Scan for viruses, Delete the browsing history.

Explanation:

I just did the test and got it right

She should follow 5 essential routine

1.) Clean your computer

2.) Do a full scan for malware

3.) uninstall any apps or programs she doesn’t use

4.) create system restore point

5.) Defragment your hard drive

A vowel word is a word that contains every vowel. Some examples of vowel words are sequoia, facetious, and dialogue. Determine if a word input by the user is a vowel word.

Answers

Answer:

vowels = ("a", "e", "i", "o", "u")

word = input("Enter a word: ")

is_all = True

for c in vowels:

   if c not in word:

       is_all = False

if is_all == True:

   print(word + " is a vowel word.")

else:

   print(word + " is not a vowel word.")

Explanation:

Initialize a tuple, vowels, containing every vowel

Ask the user to enter a word

Initially, set the is_all as True. This will be used to check, if every vowel is in word or not.

Create a for loop that iterates through the vowels. Inside the loop, check if each vowel is in the word or not. If one of the vowel is not in the vowels, set the is_all as False.

When the loop is done, check the is_all. If it is True, the word is a vowel word. Otherwise, it is not a vowel word.