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
- O conhecimento na Educação Física, normalmente passa do senso comum e vai para um conhecimento mais formal, ou seja, do conhec
neonofarm [45]

Answer:

um i don't understand you do you speak English?

Explanation:

3 0
3 years ago
Whose task it is to ensure that the product flows logically from one step to another?
AleksAgata [21]
UX i believe. Web designer and graphic designer are visual which is the basis of UI. Think of UX as User eXperience and in order to have a good experience it has to flow. If it can flow then u can design it. Think of UX as the skeleton and UI is the flesh
3 0
4 years ago
Are technical skills or people skills more important to the team manager in a software development project?
VladimirAG [237]

Answer:

A well-rounded team manager in a software development project is critical to its success. Having the best developers only gets you so far. Without proper leadership, the project will most likely fail. Developers won't know what direction to go, deadlines won't be met, and the end product will not be created to the specifications as set forth in the project. A software development team manager needs to possess both the proper technical skills to guide the developers when they get stuck, but more importantly have the proper people skills and business process skills to allow the team to work as a well-oiled machine. In this paper, we will look at two different types of team managers and how they affect the software development lifecycle.

5 0
4 years ago
Read 2 more answers
If you entered data into row 4 and it should be in row 3, you should
jeka94
 the answer in my opinion would have to be B.

3 0
3 years ago
Read 2 more answers
Aperture is the length of time that light is let into the camera in order to expose the film.
vichka [17]
I believe the answer is true.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Question 2 (1 point)
    9·1 answer
  • Can someone pls explain this question??
    7·1 answer
  • On a spreadsheet, this is the term for a grouping of cells that touch each other and form a rectangle. An example of it would be
    13·1 answer
  • Text that does not fit in a cell
    7·1 answer
  • Which type of reading is associated with an entry-level job?
    14·1 answer
  • In creating a professional action plan it's important to
    12·1 answer
  • Discuss the major differences in two approaches ofprogramming i.e. Object oriented programming and structuredprogramming.
    6·1 answer
  • Looking for friends, anyone up for it?
    12·2 answers
  • Very few games have any sort of narrative, not even a simple one that involves setting the mood through color, sound, environmen
    12·1 answer
  • Complete the sentence about bias and equity.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!