Lecture 01
Lecture 01
Peshawar, Pakistan
Lecture 1
Introduction
By;
Dr. Muhammad Athar Javed Sethi
Why Programming Language?
10001000100101
DATA
DATA 01001010101010
CPU
11100101010101
10101000011001
PROGRAM
INSTRUCTION
MEMORY
LOW AND HIGH LEVEL PROGRAMMING
10100110 01110110
#include <iostream> 00100110 00000000
11111010 11111010
int main() 01001110 10100110
{ 11100110 10010110
std::cout<<“HelloWorld”; 11001110 00101110
return 0; 10100110 01001110
11111010 01100110
}
01001110 10000110
etc...
int main()
{
std::cout<<“Hello World!”;
return 0;
}
Basic Structure of a C++ Program
int main()
output “Hello World!” {
std::cout<<“Hello World!”;
return 0;
}
Basic Structure of a C++ Program (cont)
int main()
{
std::cout<<“Hello World!”;
return 0;
every C++ program must }
have a main
Basic Structure of a C++ Program
int main()
{
Curly braces mark the std::cout<<“Hello World”;
beginning and end of a return 0;
block of instructions. }
Basic Structure of a C++ Program
return 0;
}
Basic Structure of a C++ Program
“Statements” (lines of
instructions) always end
Example: Hello World with a semi-colon (;)
C++ Program:
#include <iostream>
int main()
{
std::cout<<“Hello World”;
return 0;
}
C and C++
Traditionally C programs use the file
extension .C and C++ programs the
extension .CPP
C is essentially a subset of C++, so you
could use a C++ compiler to run a C
program. The two languages are
extremely similar.
In the labs we will be using a
Code::Blocks software (codeblocks-
16.01mingw-setup.exe).
https://sourceforge.net/projects/codeblocks/files/Binaries/16.01/Windows/
Some Programmer Jargon