Question

Q) Write a program that fills a vector object with the keywords of the C++ language....

Q) Write a program that fills a vector object with the keywords of the C++ language. Once filled, the vector elements should be displayed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>
#include <vector>

using namespace std;

int main()
{
   vector<string> v;
   v.push_back("for");
   v.push_back("while");
   v.push_back("do");
   v.push_back("return");
   v.push_back("break");
   v.push_back("continue");
   v.push_back("int");
   v.push_back("float");
   v.push_back("double");
   
   for(int i = 0;i<v.size();i++){
      cout<<v[i]<<endl;
   }
    return 0;
}

Output:

for while do return break continue int float double - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- Process exit

Add a comment
Know the answer?
Add Answer to:
Q) Write a program that fills a vector object with the keywords of the C++ language....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Program in C language for: 1. Create a C program to read 7 integers...

    Write a Program in C language for: 1. Create a C program to read 7 integers and store them in an array. Next, the program is to check if the array is symmetric, that is if the first element is equal to the last one, the value of the second one is equal to the value of the last but one, and so on. Since the middle element is not compared with another element, this would not affect the symmetry...

  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

  • Written in C++ language Write a program that keeps track of a telephone directory. The program...

    Written in C++ language Write a program that keeps track of a telephone directory. The program should create a structure, Person, with the following data: struct Person { string firstName; string lastName; string phoneNumber; }; The program should then create a vector of Person structs, called directory. Your program should have functions to: - Read the vector data from a data file “telephoneData.txt” into the vector directory. - Print the details of all Persons in the vector. You may use...

  • in C language Write a program to find the element of an array, which occurs maximum...

    in C language Write a program to find the element of an array, which occurs maximum number of times and its count. The program should accept the array elements as input from the user and print out the most occurring element along with its count. Hint: array size is 5. For example: Enter array elements (array size 5): 22321 Output: Max occurring element: 2. count: 3

  • Task 1: String with Loop • Write a program that reads a sentence and use a...

    Task 1: String with Loop • Write a program that reads a sentence and use a loop that counts how many elements in a string that are equal to ‘t’. Task 2: List with Function • Write a function fill that fills all elements of a list with a given value. • For example: o The call fill(scores, 13) should fill all elements of the list scores with the value 13. • Write a demo program to show how this...

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • language C++ Write a program to handle the flow of widgets into and out of a...

    language C++ Write a program to handle the flow of widgets into and out of a warehouse. The warehouse will have numerous deliveries of new widgets and orders for widgets. The widgets in a filled order are billed at a profit of 50 percent over their cost. Each delivery of new widgets may have a different cost associated with it. The accountants for the firm have instituted a last-in, first-out system for filling orders. This means that the newest widgets...

  • Write a program that reads a Java source-code file and reports the number of keywords (including...

    Write a program that reads a Java source-code file and reports the number of keywords (including null, true, and false) in the file. If a keyword is in a comment or in a string, don’t count it. Test your program to count the keywords in the Welcome.java file: Please input the Java filename: Welcome.java The number of keywords in the program is 6

  • Q-1: Write a program in Assembly language using MIPS instruction set that reads 15 integer numbers...

    Q-1: Write a program in Assembly language using MIPS instruction set that reads 15 integer numbers from user and stores all the numbers in the array intArray. Now, read another integer number N from the user, find the total number of array elements that are greater or equal to the number N, and the total number of array elements that are lower than the number N You must have two procedures: i. ReadIntegerArray: this procedure should read integer array elements...

  • I need help with a C++ program. Here are the instructions: Keywords: has object, passing object....

    I need help with a C++ program. Here are the instructions: Keywords: has object, passing object. 1) Implement a class named StarWars; Class StarWars has a class named World; (2 points) 2) The object starWarsOBJ created the Class Moon as a tool that Darth Vader uses to control the Class World; Therefore, having the object worldOBJ within your starWarsOBJ, pass the object moonOBJ as an argument to the worldOBJ;(2 points) 3) The moonOBJ has a huge tower that is represented...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT