SlideShare a Scribd company logo
1 of 2
Download to read offline
Intro to C/C++ Intro to Programming
MUHAMMAD HAMMAD WASEEM 1
INTRODUCTION
C++, pronounced as “See Plus Plus”, is a powerful computer programming language. It is the
advance version of C language. The C is a procedural language while the C++ is an object oriented
programming language.
STRUCTURE OF C++ PROGRAMS
A C/C++ program consists of three main parts. These are:
 Preprocessor Directives
 The main function
 C/C++ statements
Preprocessors Directives
The instructions that are given to the compiler before the beginning of the actual program are
called Preprocessor Directives. These are also known as Compiler Directives. The compiler adds special
instructions or code from these directives into the program at the time of compilation.
These preprocessor directives normally stat with a number sign (#) and the keyword “include”
or “define”.
A program example is given below. The first statement of the program is preprocessor directive.
This preprocessor has been written to include the iostream.h header file in C++ and stdio.h in C.
C Language C++ Language
#include <stdio.h>
main()
{
printf(”this is my first
program”);
}
#include <iostream.h>
main()
{
cout<<”this is my first program”;
}
Header File
Header file in C/C++ source file that contains definitions of library functions /objects. Header files
are added into the program at the compilation of the program.
The preprocessor directive “include” is used to add a header file into the program. The name of
the file is written in angle brackets (< >) after “#include” directives. It can also be written in double
quotes. The header file stdio.h / iostream.h has definitions of different built-in input and output objects
and functions. The syntax of the header file is:
#include <name of the header file>
The main () Function
The main function indicates the beginning of a C/C++ program. The main () must be included in
every C/C++ program. When a C/C++ program is executed, the control goes directly to the main ()
function. The statements within this function are the main body of the C/C++ program. If main () function
is not included, the program is not compiled and an error message is generated.
The syntax of the main function is:
main ()
{ Programs statements…. }
Intro to C/C++ Intro to Programming
MUHAMMAD HAMMAD WASEEM 2
C++ Statements
The statements of the program are written under the main () function between the curly braces
{}. These statements are the body of the program. Each statement in C/C++ ends with a semicolon (;).
C/C++ is a case sensitive language. The C/C++ statements are normally written in lowercase
letters but in some exceptional cases, these can also be written in uppercase.
Keywords
The words that are used by the language for special purposes are called keywords. These are also
called reserved words. For example, in a C/C++ program, the word main is used to indicate the starting
of program, int to declare an integer type variable etc.
These keywords cannot be used as variable names in a program.

More Related Content

What's hot

Chapter 13.1.4
Chapter 13.1.4Chapter 13.1.4
Chapter 13.1.4
patcha535
 

What's hot (20)

Lect '1'
Lect '1'Lect '1'
Lect '1'
 
C programming
C programmingC programming
C programming
 
Intoduction to c language
Intoduction to c languageIntoduction to c language
Intoduction to c language
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C programming introduction
C programming introductionC programming introduction
C programming introduction
 
OVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAMOVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAM
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
 
Chapter 13.1.4
Chapter 13.1.4Chapter 13.1.4
Chapter 13.1.4
 
Planning to computer program(southeast university)
Planning to computer program(southeast university)Planning to computer program(southeast university)
Planning to computer program(southeast university)
 
C introduction
C introductionC introduction
C introduction
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
presentation on the topic: Introduction to the C language
presentation on the topic: Introduction to the C languagepresentation on the topic: Introduction to the C language
presentation on the topic: Introduction to the C language
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
How to execute a C program
How to execute a C  program How to execute a C  program
How to execute a C program
 
Assembler
AssemblerAssembler
Assembler
 
Computer programming chapter ( 3 )
Computer programming chapter ( 3 ) Computer programming chapter ( 3 )
Computer programming chapter ( 3 )
 
Presentation on C programming language
Presentation on C programming languagePresentation on C programming language
Presentation on C programming language
 
C language
C languageC language
C language
 
C programming course material
C programming course materialC programming course material
C programming course material
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
 

Similar to [ITP - Lecture 03] Introduction to C/C++

C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 

Similar to [ITP - Lecture 03] Introduction to C/C++ (20)

C++ Chapter 3
C++ Chapter 3C++ Chapter 3
C++ Chapter 3
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
Cp week _2.
Cp week _2.Cp week _2.
Cp week _2.
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Structure of C program
Structure of C programStructure of C program
Structure of C program
 
PPs16.pptx
PPs16.pptxPPs16.pptx
PPs16.pptx
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdfC PROGRAMMING p-2.pdf
C PROGRAMMING p-2.pdf
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
Chapter 3(1)
Chapter 3(1)Chapter 3(1)
Chapter 3(1)
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
 
C programming presentation(final)
C programming presentation(final)C programming presentation(final)
C programming presentation(final)
 
Stucture of c program
Stucture of c programStucture of c program
Stucture of c program
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
 
C++ language basic
C++ language basicC++ language basic
C++ language basic
 
C structure
C structureC structure
C structure
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 

More from Muhammad Hammad Waseem

More from Muhammad Hammad Waseem (20)

[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
[ITP - Lecture 14] Recursion
[ITP - Lecture 14] Recursion[ITP - Lecture 14] Recursion
[ITP - Lecture 14] Recursion
 
[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
 
[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
 
[ITP - Lecture 09] Conditional Operator in C/C++
[ITP - Lecture 09] Conditional Operator in C/C++[ITP - Lecture 09] Conditional Operator in C/C++
[ITP - Lecture 09] Conditional Operator in C/C++
 
[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)
 
[ITP - Lecture 07] Comments in C/C++
[ITP - Lecture 07] Comments in C/C++[ITP - Lecture 07] Comments in C/C++
[ITP - Lecture 07] Comments in C/C++
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
 
[ITP - Lecture 05] Datatypes
[ITP - Lecture 05] Datatypes[ITP - Lecture 05] Datatypes
[ITP - Lecture 05] Datatypes
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
 
[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
 
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
 
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types[OOP - Lec 13,14,15] Constructors / Destructor and its Types
[OOP - Lec 13,14,15] Constructors / Destructor and its Types
 
[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing[OOP - Lec 09,10,11] Class Members & their Accessing
[OOP - Lec 09,10,11] Class Members & their Accessing
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

[ITP - Lecture 03] Introduction to C/C++

  • 1. Intro to C/C++ Intro to Programming MUHAMMAD HAMMAD WASEEM 1 INTRODUCTION C++, pronounced as “See Plus Plus”, is a powerful computer programming language. It is the advance version of C language. The C is a procedural language while the C++ is an object oriented programming language. STRUCTURE OF C++ PROGRAMS A C/C++ program consists of three main parts. These are:  Preprocessor Directives  The main function  C/C++ statements Preprocessors Directives The instructions that are given to the compiler before the beginning of the actual program are called Preprocessor Directives. These are also known as Compiler Directives. The compiler adds special instructions or code from these directives into the program at the time of compilation. These preprocessor directives normally stat with a number sign (#) and the keyword “include” or “define”. A program example is given below. The first statement of the program is preprocessor directive. This preprocessor has been written to include the iostream.h header file in C++ and stdio.h in C. C Language C++ Language #include <stdio.h> main() { printf(”this is my first program”); } #include <iostream.h> main() { cout<<”this is my first program”; } Header File Header file in C/C++ source file that contains definitions of library functions /objects. Header files are added into the program at the compilation of the program. The preprocessor directive “include” is used to add a header file into the program. The name of the file is written in angle brackets (< >) after “#include” directives. It can also be written in double quotes. The header file stdio.h / iostream.h has definitions of different built-in input and output objects and functions. The syntax of the header file is: #include <name of the header file> The main () Function The main function indicates the beginning of a C/C++ program. The main () must be included in every C/C++ program. When a C/C++ program is executed, the control goes directly to the main () function. The statements within this function are the main body of the C/C++ program. If main () function is not included, the program is not compiled and an error message is generated. The syntax of the main function is: main () { Programs statements…. }
  • 2. Intro to C/C++ Intro to Programming MUHAMMAD HAMMAD WASEEM 2 C++ Statements The statements of the program are written under the main () function between the curly braces {}. These statements are the body of the program. Each statement in C/C++ ends with a semicolon (;). C/C++ is a case sensitive language. The C/C++ statements are normally written in lowercase letters but in some exceptional cases, these can also be written in uppercase. Keywords The words that are used by the language for special purposes are called keywords. These are also called reserved words. For example, in a C/C++ program, the word main is used to indicate the starting of program, int to declare an integer type variable etc. These keywords cannot be used as variable names in a program.