100% found this document useful (1 vote)
212 views10 pages

Lecture 1 C++

This document provides an introduction to C++ programming language for a class at Duhok Polytechnic University. It discusses the basic structure of a C++ program, including important notes about case sensitivity and statement endings, as well as the main functions and statements used in C++ like #include, int main(), void main(), cout, cin, and endl. It provides two examples of simple C++ programs to print text using cout and endl.

Uploaded by

Arkan Duski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
212 views10 pages

Lecture 1 C++

This document provides an introduction to C++ programming language for a class at Duhok Polytechnic University. It discusses the basic structure of a C++ program, including important notes about case sensitivity and statement endings, as well as the main functions and statements used in C++ like #include, int main(), void main(), cout, cin, and endl. It provides two examples of simple C++ programs to print text using cout and endl.

Uploaded by

Arkan Duski
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Duhok Polytechnic University

Technical College of Engineering


H.B. Department
Class : 2nd Stage // 1st Semester

Programming Fundamental by C++


Using Visual Studio Program

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

C++ Programming Language:

Is a collection of one or more programs, called functions. The Function is a

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

to use a compiler that the computer can understand us.

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.

 Always you should ending each statement by ( ; ) semicolon symbol except of

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 :

using namespace std;

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.

{ brackets Start of the main

} brackets End of the main


5
 cout<< " ";

Computer output ( print )

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 >>

Computer input ( find and enter by user).

 <<endl ;

Text to new line.

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

3. Write your full name

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;

OR YOU CAN USE ONE (cout) :

cout<<"Hello Student"<<endl<<"H.B Department"<<endl<<"Ahmed Ahmed


Ahmed"<<endl;
}
9

You might also like