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]
2 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]2 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]2 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
PLEASE HELP ILL GIVE POINTD AND BRAINLIEST
Nastasia [14]

Answer:

I would have to say C.

Explanation:

Feel free to correct me if i'm wrong :)

Hope this helps

4 0
3 years ago
Write a story, a tale, a biography or a diary.
antoniya [11.8K]
I will write a very short story, so I hope this helps a little

The processing of gold: A diary entry

April 5/2018

I am the worlds most precious metal. 
I am worth more than any silly diamond, and far more stronger than Iron. No one can come close to being as important as I.

I start as a tiny mineral, found underground where I spend my days perfecting myself. Most might find relatives of mine in water, buried among sand and dirt. Then we are put through the most rigorous of training until we are god.

Well, gold, but you know what I mean.

Once I am perfection, I will be sold among the masses of people.   I will be loved my all and crafted into everything. If I wanted, I could take over the world...a world of just gold, wouldn't that be magical?

Today I think I will be made into a ring, I hope I am not squeezed on some fat woman's finger.

I hope this helps a little, Cheers :)

6 0
3 years ago
Match the tool to the task it helps to accomplish.
olga2289 [7]

Answer:

Translate ➡️ allows the user to change words from one language to another

Smart Lookup➡️allows user to find the definition of a word or a phrase.

Thesaurus ➡️ allows the user to find the synonyms and antonyms of a word.

Explanation:

I have been able to match each took to the tasks that they perform.

In Translate, users can easily change words into a different language. That means that words in English can be translated into French, Spanish, etc., and vice versa.

In Smart Lookup, users can actually find definitions of words or phrases. Smart Lookup can be found in Microsoft Word Office.

The Thesaurus is used to find the synonyms and antonyms of words.

These tools make learning very easy and enjoyable.

8 0
3 years ago
Please answer this please solve it
natulia [17]

Answer:

If you still can't figure it out look this up

nvcc cafe problem

Explanation:

4 0
3 years ago
A particularly devastating type of dos attack is the ____ dos attack, in which multiple unsuspecting computers are used to attac
IgorLugansk [536]
Distributed






---------------------
3 0
3 years ago
Other questions:
  • *****NEED HELP ASAP!!!! COMPUTER HELP!!!! PLEASE!**
    13·1 answer
  • The TabIndex value assigned to a text box's identifying label must be _______________ for the text box's access key to work corr
    14·1 answer
  • The rod and crankshaft convert the up-and-down motion of the piston into
    5·2 answers
  • Write the name of the tab, the command group, and the icon that you need to use to justify
    14·1 answer
  • What is the difference between a try block and a try statement? Group of answer choices There is no difference; the terms can be
    6·1 answer
  • Digital signatures are as legally acceptable as written signatures.
    12·1 answer
  • Select the correct answer
    15·1 answer
  • Choose ALL guidelines listed below pertaining to fair use.
    12·2 answers
  • Project stem test 3 answers
    14·1 answer
  • Select the correct answer. Which step references adding color, size, and media format in your digital portfolio? A. identifying
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!