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
Sami is creating a web page for her dog walking business. Which item will set the theme for her page? Background color Heading c
bazaltina [42]

Answer:

A Background color

Explanation:

7 0
3 years ago
Whose massively popular photo led to the creation of google images?
Alex
Jennifer Lopez’s picture led to the creation of google images.
5 0
3 years ago
PLS HURRY <br> Look at the image below
fenix001 [56]

Answer:

one sec

what is that called?

if you have more than one try

then you should just take an "EDUCATIONAL GUESS"

it's a 50/50 chance

just take it

Explanation:

<h2><u><em>YOU GOT THIS MAN! :3</em></u></h2>

8 0
3 years ago
Choose the correct term to complete the sentence.
Diano4ka-milaya [45]

Answer:

Object-oriented programming

Explanation:

When used in object-oriented programming , a class is a factory for creating object. An object is a collection of data and behavaiors that represent some entity(real or abstract).

6 0
3 years ago
1. Actuators apply mechanical force in the form of pressure to overcome
Harman [31]
The answer is d torque because
3 0
3 years ago
Other questions:
  • rob just got a new idea for the movie he's making, and he wants to put in late hours to get it done. Which of the following stat
    10·1 answer
  • A ____ by a design professional is used to determine the best system to provide the appropriate level and type of protection.
    6·1 answer
  • The common programming structure that implements "conditional statements" is called an____ statement.
    8·1 answer
  • 1 megabyte is equal to 1024 gigabyte. True/False​
    11·2 answers
  • You are given an integer N, followed by N lines of input (1 &lt;= N &lt;= 100). Each line of input contains one or several words
    8·1 answer
  • Katy and her associates are approached by an aged tai chi expert to create a website for him. From her participation in an onlin
    9·1 answer
  • Clarissa is a computer programming consultant. When a client states that they have an extremely complex programming task, which
    10·2 answers
  • Question 7 (True/False Worth 3 points)
    8·2 answers
  • What is a mod in programming?<br><br> Give more Java questions
    12·1 answer
  • What are some positive impacts technology has on the environment?​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!