C++ Exercises

Fill in the blanks to complete the code.

1

Include the iostream header

#include <>
2

Output text using cout

std:: << "Hello C++" << std::endl;
3

Declare a class named Vehicle

Vehicle { public: std::string name; };
4

Create a vector of integers

std::<int> nums = {1, 2, 3};
5

Use auto to infer the type

x = 3.14;
6

Declare a std::string variable

std:: greeting = "Hello";
7

Add an element to a vector

nums.(42);
8

Use a range-based for loop over a vector

for ( val : nums) { std::cout << val; }