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

C++ Write a program that initially asks a user to enter two positive integer numbers a and b. If either a or are zero or negativ

e, the program terminates right away. Then, generate an array of 20 integer numbers, each randomly generated between a and b. If b happens to be greater than a, then the array must contain elements randomly generated between b and a. Display the whole array on the screen. After creating and displaying the array, the program shows:
[A]verage [S]um [F]ind Please choose an option: Then, if the user selects:
- A (lowercase or uppercase): the program computes and displays the average of all elements of the array
-A (lowercase or uppercase): the program computes and displays the average of all elements of the array
-F (lowercase or uppercase): the program asks the user to insert an integer number to be found in the array
If present, the program displays "Found in position number followed by the position of the first occurrence.
If not present, the program displays "Number not found in the array"
Computers and Technology
2 answers:
qaws [65]3 years ago
5 0

Answer:

#include <iostream>

#include <algorithm>

using namespace std;

int main(){

int a, b, c[20], search, maxi, mini, totalSum = 0;

char option;

int * p;

cout<< "Enter value for a: ";

cin>> a;

cout<< "Enter value for b: ";

cin>> b;

if (a == 0 || b == 0){

cout<< "Both values must be greater than zero.";

} else if(a>b){

maxi = a;

mini = b;

}

else{

maxi = b;

mini = a;

}

for (int i =0; i < 20; i++){

c[i] = (rand() % maxi) + mini;

totalSum += c[i];

}

cout << "Please choose an option: 1 , 2, 3 ";

cin>> option;

option = tolower(option);

switch(option){

case 1:

cout << "The Average of the array items is: "<< totalSum/20;

break;

case 2:

cout<< "The sum of the array items is: "<< totalSum;

break;

case 3:

cout<< "Enter number to be searched: ";

cin>> search;

p = find (c, c+20, search);

if (p != c+20)

{

cout << "Element found in c array: " << *p << '\n';

}else{

cout << "Element not found in c array\n";

}

break;

}

}

Explanation:

The C++ source code prompts the user for the a,b, option and search values and executes either of the options from the switch statement. Is correct

Explanation:

Great work person above me! :)

Brut [27]3 years ago
3 0

Answer:

#include <iostream>

#include <algorithm>

using namespace std;

int main(){

   int a, b, c[20], search, maxi, mini, totalSum = 0;

   char option;

   int * p;

   cout<< "Enter value for a: ";

   cin>> a;

   cout<< "Enter value for b: ";

   cin>> b;

  if (a == 0 || b == 0){

      cout<< "Both values must be greater than zero.";

  } else if(a>b){

        maxi = a;

       mini = b;

   }

else{

        maxi = b;

        mini = a;

   }

    for (int i =0; i < 20; i++){

        c[i] = (rand() % maxi) + mini;

        totalSum += c[i];

    }

   cout << "Please choose an option: 1 , 2, 3 ";

   cin>> option;

   option = tolower(option);

   switch(option){

       case 1:

           cout << "The Average of the array items is: "<< totalSum/20;

           break;

        case 2:

           cout<< "The sum of the array items is: "<< totalSum;

           break;

       case 3:

            cout<< "Enter number to be searched: ";

            cin>> search;

             p = find (c, c+20, search);

             if (p != c+20)

{

                cout << "Element found in c array: " << *p << '\n';

             }else{

                 cout << "Element not found in c array\n";

             }

             break;

   }

}

Explanation:

The C++ source code prompts the user for the a,b, option and search values and executes either of the options from the switch statement.

You might be interested in
Which of the following CANNOT be done in Normal view A. Enter bolded text in the Notes Pane B. Delete previously entered notes i
blondinia [14]

Answer:

<em>Well, Your answer will be is </em><em>B. Delete previously entered notes in the Notes Pane. Good Luck!</em>

3 0
4 years ago
A database administrator (DBA) must have a clear understanding of the fundamental business of an organization, be proficient in
Alexus [3.1K]

Answer: True

Explanation:

 Yes, the given statement is true that the DBA (Database administrator) utilize particular programming to store and arrange information.

The DBA is the proper understanding of the comprehension of the key business of an association, be capable in the utilization of chose database the executives frameworks, and remain side by side of developing advancements and new plan draws near.

The main purpose of the database administrator that it incorporate scope organization, establishment, setup, database plan, movement, execution checking, security, investigating, just as reinforcement and information recovery.

8 0
4 years ago
What is a dropcap as used in a computer word document
shutvik [7]

DROP CAP:-

<u>Drop caps are a specific kind of initial letter, large letters that appear at the beginning of a block of text. ... A drop cap is often used to signify that the reader's moved into a significant new section, or that a new chapter's begun.</u>

<u>Drop caps are a specific kind of initial letter, large letters that appear at the beginning of a block of text. ... A drop cap is often used to signify that the reader's moved into a significant new section, or that a new chapter's begun.A drop cap (dropped capital) is a large capital letter used as a decorative element at the beginning of a paragraph or section. The size of a drop cap is usually two or more lines. The following illustration shows your options for positioning a drop cap.</u>

3 0
3 years ago
A hammer has an input distance of 2 cm and an output distance of 7 cm. What is its ideal mechanical advantage?
KATRIN_1 [288]

Answer: 4

What is its ideal mechanical advantage?

Explanation:

6 0
3 years ago
Processing record using a class python
ehidna [41]

Answer:

Explanation:

Using regular Python classes as record data types is feasible, but it also takes manual work to get the convenience features of other implementations.

4 0
3 years ago
Other questions:
  • A collection of related instructions organized for a common purpose is referred to as
    6·2 answers
  • Mia is attending a team meeting to discuss how to prevent accidents. One of her teammates suggests pushing all the desks against
    15·2 answers
  • When using the red / yellow / green method to present status of a project, yellow can mean which of the following? A. There are
    5·2 answers
  • Why was unicode invented?
    5·2 answers
  • What system of representation is used for the threaded portions
    12·1 answer
  • What did research conducted in 2009 at Carnegie University Mellon predict?
    12·1 answer
  • Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
    15·1 answer
  • How is the bootstrap program started?
    6·2 answers
  • What is the output of this program?
    7·1 answer
  • State the keyboard key used to move the cursor to the line​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!