Lecture 1 C++
Lecture 1 C++
Practical
Academic Year : 2019 – 2020
Lecturers
Dr. Idrees Kocher
Salar Faisal Brifcani
“Lecture One”
Introduction to C++ Programming Language
1
Introduction to C++ Programming Language
collection of statements that perform something and C++ have many function that
we can use. Every C++ program has a function called main. At the end we need
Compiler : is the program that translates C++ programming language into the
machine language binary (0 and 1), the compiler also check the error in the
program.
2
IMPORTANT NOTES
C++ program language is case sensitive, example (A) is not equal to (a).
Always you should use small letters when you write C++ code.
some functions.
3
The general structure of C++ program
First of all when you write your code you should always begin with:
#include<iostream.h> OR #include<iostream>
This is an important statement that tells the compiler to include iostream files.
This file contains Input/output functions that we can use in our program.
P.S // If you use #include<iostream> then after that you should write :
4
There are two main functions in C++ program:
1. int main()
This is the main function of the C++ program also you must write this function
after #include<iostream.h>. This function have a return type which indicates to
the compiler that this function will return a integer value, that is the main
reason to write ( return 0; ) statement at the end of main function.
2. void main()
Also this is the main function that you can write after the
#include<iostream.h> but this function do not return any value.
This function will print on black screen any think that you write inside the double
quotation. Outside the double quotation will print the value.
cin >>
<<endl ;
6
Ex 1 // Write C++ program to print the text (welcome to C++) using visual
studio?
Solution Ex 1 //
#include<iostream>
using namespace std;
void main()
{
cout<<"welcome to c++"<<endl;
}
7
Ex 2 // Write C++ program to print three text in separate lines using visual
studio?
1. Hello Student
2. H.B Department
8
Solution Ex 2 //
#include<iostream>
using namespace std;
void main()
{
cout<<"Hello Student"<<endl;
cout<<"H.B Department"<<endl;
cout<<"Ahmed Ahmed Ahmed"<<endl;