008 Using cout and the insertion operator to say Hi to Frank

Instructions

IMPORTANT

GENERAL INSTRUCTIONS FOR CODING EXERCISE
Please Read
--------------------------------------

These Coding Exercises are designed to be executed in the Udemy Testing Environment within your browser.

Please do NOT try executing these coding exercises in your IDE as you will encounter issues.


Note that the Coding Exercises have no main() function available to you.
That is because I am using the main() function on my end to call and test your code.

In some Coding Exercises, you may see code elements that we haven't discussed yet.
That's because I need them to be able to execute and test your code.
You don't have to worry about not knowing them.

You just need to enter your code between the comments provided.

//--- WRITE YOUR CODE BELOW THIS LINE----  
     
//--- WRITE YOUR CODE ABOVE THIS LINE----

The code you will enter will be what is covered in the associated lectures.

Have fun and take advantage of these Coding Exercises to practice!

Finally, sometimes the code isn't rendered in the browser correctly and may seem to be missing some parts. I would encourage everyone to click on the 'Reset' button the first time they attempt a coding exercise. This will ensure that the code is displayed properly in the browser.

END OF INSTRUCTIONS

--------------------------------------

Coding Exercise #1

Write a single output statement using cout  that displays "Hi Frank!" to the console. Please don't have to use a '\n ' orendl , just display the text.

Note: only a single cout statement should be used for this challenge - no other code is necessary.


You can find my solution by clicking the solution.txt file on the left pane. But please make sure you give it a go yourself first, and only check the solution if you really get stuck.

Test(s)

Test 1

#include "gtest/gtest.h"
#include "helpers/iohelper.h"

void say_hi();

namespace {

class Evaluate : public ::testing::Test {};

TEST_F(Evaluate, Message) {
    std::pair output = CAPTURE_OUTPUT(say_hi());
    std::string stdout = output.first;
    EXPECT_EQ("Hi Frank!", stdout) << "Your code should display: Hi Frank!";
}

}  // namespace

Solution(s)

Solution 1

#include 

using namespace std;

void say_hi() {
    // --- WRITE YOUR CODE BELOW THIS LINE----  
    
    cout << "Hi Frank!";
    
    //--- WRITE YOUR CODE ABOVE THIS LINE----
}

Solution 2

#include 

using namespace std;

void say_hi() {
    // --- WRITE YOUR CODE BELOW THIS LINE----  
    
    cout << "Hi Frank!";
    
    //--- WRITE YOUR CODE ABOVE THIS LINE----
}