STARTING OUT WITH C++ MPL
STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
Question
Book Icon
Chapter 16, Problem 10PC
Program Plan Intro

Two Dimensional Data

Program Plan:

  • Include the required header files.
  • Define the function getData(),
    • Declare and initialize the variable.
    • Loop executes until k is less than number. If yes,
      • Read the index of the tourists from file.
      • Store the tourists name into vector.
    • Loop executes until k is less than number. If yes,
      • Read the index of the tourists from file.
      • Loop executes until j is less than numberDestinations. If yes,
        • Read the destination from the file.
        • Add the favorite destination for each person.
      • Store the favorite destination for each person into another vector.
  • Define the function indexOf(),
    • Loop executes until the k is less than size of vector. If yes,
      • Check whether the name is equal to vector name. If yes,
        • Return the k value.
    • Exit the function
  • Define the “main()” function.
    • Create object to open the file.
    • Check for file existence. If yes,
      • Display the file status.
    • Declare the two vectors.
    • Call getData() function retrieves data from the file and stores it into two vectors.
    • Loop executes until k is size of tourists. If yes,
      • Display the names of tourists
    • Display the statement.
    • Loop executes until true. If yes,
      • Read the name of the tourist from user.
    • Check name is equal to quit. If yes, exit the program.
    • Call the indexOf() function returns the index of a string in a vector of strings.
    • Check the index is equal to -1. If yes,
      • Display the statement.
      • Continue the program.
    • Loop executes until the end of the vector. If yes,
      • Display the statement.
      • Increment iteration by 1.

Blurred answer
Students have asked these similar questions
Problem: • Assume that we have a matrix that stored inside a file and it contains monthly salary of each employee of a company. The matrix column starts from month 1 to 12, and for the rows you can enter data for 6 employees minimum. • The output of the program must be the annual salary of each employee of the company.
İn C language
An array is a sequence of data items that are of the same type, that can be indexed, and that are stored contiguously. Typically,an array is called a data structure used to represent a large number of homogeneous values. The elements of an array are accessedby the use of subscripts. Subscripts start from zero and runs until less than the size of the array. Arrays of all types are possible,including multi-dimensional arrays. Strings are just arrays of characters terminated by a special character called the null character.A typical array declaration allocates memory starting from a base address. The array name is in effect a constant pointer to thismemory address.a) Write a complete C program that demonstrates the usage of character strings. The program should declare an emptycharacter array of specific size, and then ask user to enter a string to be stored in the array using a scanf function. Theprogram should finally display the string entered to the screen for checking if the…

Chapter 16 Solutions

STARTING OUT WITH C++ MPL

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning