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
vodomira [7]
3 years ago
9

Write a complete C++ program that do following. Read a positive integer from the user with proper prompt. Assume that this user

is nice and he/she would not start the integer with digit 0. Create a size 10 array as counters for digits 0 - 9 Use a while loop for processing

Computers and Technology
1 answer:
exis [7]3 years ago
5 0

Answer:

The cpp program for the given scenario is shown below.

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

//variable for while loop

   int n=0;

   //size of array declared

   int size=10;

   //integer array declared

   int num[size];

   //user enters elements for the array inside while loop

   while(n<size)

   {

       std::cout << "Enter a positive number: ";

       cin>>num[n];

n++;

   }

   std::cout << "Thanks for entering the numbers. Program ends." << std::endl;

   return 0;

}

Explanation:

1. The integer variable, size, is declared and initialized to hold the size of the array.

int size=10;

2. Another integer variable, n, is declared to be used in the while loop.

int n=0;

3. An integer array, num, is declared having the capacity of integer variable, size.

int num[size];

4. Inside the while loop, the user is prompted to enter a positive number.

std::cout << "Enter a positive number: ";

5. The user-entered number is assigned directly to the array.

cin>>num[n]

6. After input is taken, the variable n is incremented by 1.

n++;

7. The while loop executes over variable n for the range of values from 0 to size-1,  i.e., until the array is filled. The first index of the array is 0 and increments henceforth. The variable is declared outside the loop unlike the for loop.

while(n<size)

8. In this program, all the code is written inside main().

9. Since cpp is not a purely object-oriented language, it is not mandatory to write the code inside the class for a simple program like this.

10. The program ends with a message for the user.

std::cout << "Thanks for entering the numbers. Program ends." << std::endl;

11. The return statement indicates the end of main() method.

return 0;

12. The output of the program is attached as an image.

13. The program can be tested for any value of variable size.

You might be interested in
What do you think about the future of Moore’s Law? Will it continue to hold true? Will other technologies help us keep on track?
Sveta_85 [38]

There will come a time when Moore's law can no longer hold true. Past a certain point, it will be physically impossible to make a transistor any smaller. Microscopic technology will always be limited by the size of an atom. Yes, Moore's law can be regarded as a self-fulfilling prophecy, because tech companies do not want to fail to keep up with it.

4 0
3 years ago
Our Client, a renowned trading company, suffered a sudden, devastating power outage that caused their server to cease functionin
Norma-Jean [14]

Answer:

Explanation:

I will consult the following strategies:

Step 1: Being a discerning consultant I should be knowing what exactly has caused the drive to get corrupted.

Step 2: After examining the current state of the hard drive I will explain the actual problem to the client in a very lucid and eloquent manner whether it is feasible to retrieve the lost data or it is beyond repair.

Step 3: Identify a solution to the problem with things at my disposal(finding a right tool).

Step 4: apply the solution found to retrieve the data from the hard drive.

Step 5: submitting the retrieved data from the corrupt drive to the customer and advocating them the preventive measures for future reference.

The above five steps will work perfectly to resolve the issue faced if followed with great care and being heedful of the situation at hand.

6 0
3 years ago
What does BMP stand for?
OverLord2011 [107]
Hello there!

It is Bitmap.

Hope This Helps You!
Good Luck :)
6 0
3 years ago
Read 2 more answers
g Points The critical section cannot be executed by more than one process at a time. false true Save Answer Q3.28 Points The cod
Ira Lisetskai [31]

Answer: Hello your question lacks some details attached below is the missing detail

answer :

a) True , B) False  C) True  D) True

Explanation:

a) True ; The critical section cannot be executed by more than one process at a time

b) False : The code does not satisfy the progress condition, because while loops are same hence no progress

c ) True :  The code satisfies the bounded waiting condition, because of the waiting condition of the while loop

d) True : No matter how many times this program is run, it will always produce the same output, this is because of the while loop condition

7 0
3 years ago
Assume a system has a TLB hit ratio of 90%. It requires 15 nanoseconds to access the TLB, and 85 nanoseconds to access main memo
andriy [413]

Answer:

310 ns

Explanation:

Given that

TLB hit ratio = 90%

TLB hit ratio = 90/100

TLB hit ratio = 0.9

Time needed to access TLB = 15 ns

Time needed to access main Memory = 85 ns

Effective memory access time = ?.

The formula for finding the effective memory access time is given by

The effective memory access time = [TLB Hit ratio (main memory access time + required time to access TLB) + [2 * (main memory access time + required time to access TLB)] * (2 - TLB hit ratio)]

On substituting the values given in the question to the equation, we have

The effective memory access time = [0.9 (85 + 15) + [2 * (85 + 15)] * (2 - 0.90)]

The effective memory access time =

[(0.9 * 100) + (2 * 100) * 1.1]

The effective memory access time =

(90 + (200 * 1.1))

The effective memory access time =

90 + 220

The effective memory access time =

310 ns

3 0
3 years ago
Read 2 more answers
Other questions:
  • How could a system be designed to allow a choice of operating systems from which to boot? What would the bootstrap program need
    14·1 answer
  • In 1913, __________ developed a mass production system for cars that made it possible to produce more cars in a shorter period o
    5·2 answers
  • How is DATA sent across a Network?
    7·1 answer
  • Whoever answers int the next 15 minutes will get brainliest. To get brainliest, it also has to be the correct answer. 8 points r
    11·2 answers
  • Linela Insurance needs to hire twenty accountants immediately to support its accounts receivable process. The hiring and trainin
    7·1 answer
  • What of the following is not a benefit of active listening
    8·2 answers
  • From a database point of view, the collection of data becomes meaningful only when it reflect
    8·1 answer
  • Who when and why developed python​
    9·2 answers
  • NEED HELP ASAP
    13·2 answers
  • Type of cable installed on a patch panel?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!