Answer to Question #174873 in C++ for Caleb

Question #174873

Do a C++ code to create the following output using only two or more parallel arrays:

Create two parallel arrays, one for actors or actresses and one for their phone numbers with the following data:

 

Actors: Angelina Jolie, Brad Pitt, Margot Robbie, George Clooney, Jennifer Lopez, Jennifer Lawrence

Info: 949-232-1124, 949-865-3492, 864-235-7569", 939-453-2288, 987-209-2132, 543-239-8745

 

Prompt the user for a number from 1 to 6 and based on the number, display the actor’s name and related phone number. If the number is not between 1 to 6, an error message as you see below should be displayed.

 

You should prompt the user if he or she likes to continue and upon Y or y you clear the screen and repeat until the response is N or n 


1
Expert's answer
2021-03-24T01:56:28-0400
include <iostream>
#include <string>

using namespace std;
int main() {
   int max = 0, index = 0;
   string actors [ ] = { "Angelina Jolie"," Brad Pitt", "Margot Robbie", "George Clooney", "Jennifer Lopez", "Jennifer Lawrence"};
   int info[ ] = { 949-232-1124, 949-865-3492, 864-235-7569", 939-453-2288, 987-209-2132, 543-239-8745};

   char arr[10], index=0;
    int i, n, pos;
    cout << "Enter size of the array : ";
    cin >> n;
    cout << "\nEnter elements of the array : ";
    for (i = 1; i <= n; i++)
        cin >> arr[i];
    cout << "\nEnter the position : ";
    cin >> pos;
    for (i = 1; i <= n; i++)
        if (pos == i)
            index= arr[i];
    cout << "\nElement at position " << pos << " is : " << ele;
   
   return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS