Week 1 - Lecture 2 - Basics of C++, Good Programming
Week 1 - Lecture 2 - Basics of C++, Good Programming
Dr Taimur Ahmed
Lecture# 2
Basic of Typical C++ Environment, Good
Programming Practice
Introduction to Programming
❑ What is a Program?
➢ A program is a precise sequence of steps to solve a particular problem
➢ A complete set of activities to be performed in a particular order –
what’s the purpose?
❑ What is Programming?
➢ A process of designing and building an executable computer program to
accomplish a specific computing result or to perform a specific task
➢ e.g solve some mathematical problems, video game for fun, edit
images/videos, an app to browse internet or send/receive
emails/messages, etc
❑ Namespace
➢ std:: specifies using name that belongs to “namespace” std
➢ std:: can be removed through use of following statements
1 // Lecture 2
2 // Printing a line with multiple statements.
3 #include <iostream>
4
5 // function main begins program execution Multiple stream insertion
6 int main() statements produce one line
7 {
of output.
8 std::cout << "Welcome ";
9 std::cout << "to C++!\n";
10
11 return 0; // indicate that program ended successfully
12
13 } // end function main
Welcome to C++!
Welcome
to
C++!
Loader
Loader puts program
..
in memory (RAM)
Run ..
..
(load and execute)
CPU takes each instruction and executes it, possibly
./foo, a.out
CPU storing new data values in memory (RAM) as the
..
..
program executes.
..