Personalized C++ Greeting

C++C++Beginner
Practice Now

Introduction

Welcome to your very first C++ programming challenge! This exercise is designed to be a gentle introduction to C++ programming. You'll work with a pre-written program and make a small but important modification. This challenge will help you understand how to edit, compile, and run a C++ program.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL cpp(("`C++`")) -.-> cpp/IOandFileHandlingGroup(["`I/O and File Handling`"]) cpp(("`C++`")) -.-> cpp/BasicsGroup(["`Basics`"]) cpp/IOandFileHandlingGroup -.-> cpp/output("`Output`") cpp/BasicsGroup -.-> cpp/variables("`Variables`") cpp/BasicsGroup -.-> cpp/strings("`Strings`") subgraph Lab Skills cpp/output -.-> lab-391809{{"`Personalized C++ Greeting`"}} cpp/variables -.-> lab-391809{{"`Personalized C++ Greeting`"}} cpp/strings -.-> lab-391809{{"`Personalized C++ Greeting`"}} end

Complete the Greeting Program

In this challenge, you'll complete a simple C++ program that greets you by name. The program is already written, but it's missing your name. Your task is to add your name to the program so that it greets you personally.

Tasks

  • Open the pre-created file greeting.cpp in the ~/project directory
  • Locate the incomplete line in the program
  • Add your name as a string to complete the program

Requirements

  • Edit the file greeting.cpp in the ~/project directory
  • Replace the placeholder "YOUR_NAME" with your actual name (or any name you choose)
  • Do not modify any other part of the code

Example

Here's an example of how to compile and run your program, and what the output might look like:

$ g++ greeting.cpp -o greeting
$ ./greeting
Hello, Alice!
Welcome to C++ programming, Alice!
alt text

Note: In this example, "Alice" is the name that was used. Your output will show the name you chose instead.

Summary

In this challenge, you've taken your first steps in C++ programming by:

  1. Editing a pre-existing C++ program
  2. Understanding the basics of string variables in C++
  3. Compiling and running a C++ program

This exercise introduced you to the process of working with C++ code, from editing to execution. As you continue your journey in C++ programming, remember that every program starts with small, manageable steps like these.

Other C++ Tutorials you may like