200k views
5 votes
Complete the program by entering the missing statements. Input: Student Name, Age Example Input: Mark, 25 Produce the following Example Output: Hello Mark. Your age is 25. ------------------------- void main() { String name; float age; cout <<"Enter your name: "; //missing instruction. Use getline() cout <<"Enter your age: "; //missing instruction //missing output instruction }

User Filimindji
by
7.1k points

1 Answer

5 votes

Answer:

The solution code is written in C++

  1. void main() {
  2. String name; float age;
  3. cout <<"Enter your name: ";
  4. getline(cin, name);
  5. cout << "Enter your age: ";
  6. cin >> age
  7. cout<< "Your name is: " << name;
  8. cout<< "and your age is: " << age;
  9. }

Step-by-step explanation:

All the missing codes are highlighted in the code above (Line 4, 6, 8-9).

The getline() method is to get a string of name from user. The input string will be assigned to variable name. (Line 4)

Next, we use cin to get an integer input for variable age (Line 6).

At last, the output instruction to print out the name and age are written in Line 8 - 9.

User MikeyBeLike
by
7.2k points