Professional Documents
Culture Documents
Introduction To C
Introduction To C
As the name implies, C++ was derived from the C language; Bjarne’s goal was
to add object-oriented programming into C, a language well-respected for its
portability and low-level functionality.
In this lesson, we’ll start learning some basic concepts, and you’ll write your
very first C++ program.
Note: Don’t worry if some words don’t make much sense right now. We’ll
learn about them in a bit!
Hello World!
Take a look at the hello.cpp file in the code editor that is placed in the middle
of the screen. It’s a C++ program!
C++ programs are stored in files which usually have the file extension .cpp,
which simply stands for “C Plus Plus”.
The code inside our C++ file is a classic first step all new programmers take —
they greet the world through the terminal!
The terminal is the black panel on the right. It should be blank right now. The
code in the text editor will print text out onto the terminal. More specifically, it
will print the phrase Hello World!.
Before we explain what all that mumbo jumbo is, let’s run the program to see
what happens.
Instructions
int main() {
std::cout << "Hello World!\n";
Hello World!
Output:
Output
High five! We just got your first program to run.
C++, like most programming languages, runs line by line, from top to bottom.
Here is the structure of a C++ program:
In between the curly braces is what we are going to focus on for now.
std::cout is
the “character output stream”. It is pronounced “see-out”.
<< is an operator that comes right after it.
"Hello World!\n" is what’s being outputted here. You need double quotes
around text. The \n is a special character that indicates a new line.
; is a punctuation that tells the computer that you are at the end of a
statement. It is similar to a period in a sentence.
Instructions
int main() {
}