An Introduction to C++
What If You Could Talk to a
Computer?
● Have you ever wondered what it
would be like to talk to a computer?
● How do you think computers
understand what we want them to
do?
● Today, we'll learn how to
communicate with computers using a
language called C++!
Say Hello to the World!
● Let's look at our first C++ program:
● #include <iostream>
● using namespace std;
● int main() {
● cout << "Hello, World!";
● return 0;
● }
● What do you think this code will do?
Key Features of C++
Object-oriented programming (OOP) support
•Low-level memory manipulation
•Fast execution speed
•Large standard library
•Cross-platform compatibility
C++ in real world :
•Operating systems (Windows, parts of macOS)
•Web browsers (Google Chrome, Mozilla Firefox)
•Database management systems (MySQL)
•Space exploration (NASA software)
•Weather forecasting models
•Medical imaging systems
•Games such as Minecraft (partially),Fortnite.
Breaking Down the Code
● Let's understand what each part does:
● #include <iostream>: This tells the computer we want
to use input/output features
● using namespace std: This helps us use common C++
tools
● int main(): This is where our main program starts
● cout: This is how we tell the computer to display
something
What is cout?
● cout stands for "character output"
● It's like a megaphone for your
computer
● Whatever you put after cout << will
be displayed on the screen
● Can you guess what cout << "I love
coding!"; would do?
Let's Experiment!
● Now it's your turn to try!
● Can you modify the code to make it say your name?
● Try: cout << "Hello, [Your Name]!";
● What happens if you add more cout lines?
Multiple Lines of Output
● You can use multiple cout statements
to print on different lines:
● cout << "Line 1";
● cout << "Line 2";
● But wait, why are they on the same
line? Any guesses?
The Power of endl
● To move to a new line, we use endl
● Try this:
● cout << "Line 1" << endl;
● cout << "Line 2" << endl;
● What's the difference? How does it look now?
Combining Strings and
Numbers
● C++ can print both text (strings) and
numbers
● Example:
● cout << "I am " << 13 << " years
old." << endl;
● Can you modify this to show your
age?
Math with cout
● cout can also do math for us!
● Try this:
● cout << "10 + 5 = " << 10 + 5 << endl;
● Can you make it do subtraction? Multiplication?
Special Characters
● C++ uses some special characters for
formatting
● \n: Creates a new line (like endl)
● \t: Adds a tab space
● Try: cout << "Hello\tWorld\nHow are
you?";
● What does this output look like?
Emoji Challenge!
● Let's have some fun with text art!
● Can you create a smiley face using cout?
● Hint: Use characters like : - ) ( and others
● Example: cout << ":-)";
● Try to make your favorite emoji!
Your Challenge?
1.We've just scratched the surface of C++
2.You can create games, solve complex problems, and
much more!
3.Create tasks they can relate to:
o Print a short menu for a pretend restaurant.
o Display a scoreboard for a game.
Remember, every expert started where you are now.
Keep coding!