Sinux1

PS7Q5.cpp

Apr 13th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main()
  8. {
  9.     int num_names = 5;
  10.     string friend_list[5];
  11.     int friend_list_id[5];
  12.  
  13.    cout << "Enter five names\n";
  14.  
  15.    for (int index = 0, num_friend = 1; index < 5; index++, num_friend++)
  16.         {
  17.             cout << "Enter friend " << num_friend << endl;
  18.             cin >> friend_list[index];
  19.             friend_list_id[index] = num_friend;
  20.         }
  21.  
  22.     cout << "Here are all of those names\n";
  23.  
  24.     for (int index = 0; index < 5; index++)
  25.         {
  26.             cout << "Friend " << friend_list_id[index] << " is " << friend_list[index] << endl;
  27.         }
  28.     int best_friend;
  29.     cout << "Which friend is your best friend? (Enter an integer)\n";
  30.     cin >> best_friend;
  31.  
  32.     for (int index = 0; index < 5; index++)
  33.     {
  34.         if (best_friend == friend_list_id[index])
  35.         {
  36.             cout << friend_list[index] << "? Yes, " << friend_list[index];
  37.             cout << " is awesome\n";
  38.  
  39.         }
  40.  
  41.     }
  42. return 0;
  43. }
Add Comment
Please, Sign In to add comment