Basics of C++ Programming: A Quick Overview

undefined
 
By: Mrs. Afreen Mukhtar Solkar
 
1
 
LECTURE-2
 
cout<<“Hello World”;
This line is a C++ statement. It is the statement that
produce some effect in the program.
و
ه‍
‍ذ
ا
 
ا
ل‍
‍خ‍
‍ط
 
ه‍
‍و
 
+
+
 
C
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن
.
 
ه‍
‍و
 
ب‍
‍ي‍
‍ا
ن
 
أ
ن
 
ت‍
‍ن‍
‍ت‍
‍ج
 
ب‍
‍ع‍
‍ض
 
ا
ل‍
‍ت‍
‍أ
ث‍
‍ي‍
‍ر
 
ف‍
‍ي
ا
ل‍
‍ب‍
‍ر
ن‍
‍ا
م‍
‍ج
.
The statement always ends with a semi colon (;).
ب‍
‍ي‍
‍ا
ن
 
ي‍
‍ن‍
‍ت‍
‍ه‍
‍ي
 
د
ا
ئ‍
‍م‍
‍ا
 
م‍
‍ع
 
ف‍
‍ا
ص‍
‍ل‍
‍ة
 
م‍
‍ن‍
‍ق‍
‍و
ط‍
‍ة
 
(
؛
)
.
This character is used to mark the end of the
statement.
و
ي‍
‍س‍
‍ت‍
‍خ‍
‍د
م
 
ه‍
‍ذ
ا
 
ا
ل‍
‍ح‍
‍ر
ف
 
ب‍
‍م‍
‍ن‍
‍ا
س‍
‍ب‍
‍ة
 
ن‍
‍ه‍
‍ا
ي‍
‍ة
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن
.
return 0;
The return statement causes the main function to
finish.
ي‍
‍ت‍
‍س‍
‍ب‍
‍ب
 
ف‍
‍ي
 
ب‍
‍ي‍
‍ا
ن
 
ع‍
‍و
د
ة
 
و
ت‍
‍ت‍
‍م‍
‍ث‍
‍ل
 
ا
ل‍
‍م‍
‍ه‍
‍م‍
‍ة
 
ا
ل‍
‍ر
ئ‍
‍ي‍
‍س‍
‍ي‍
‍ة
 
لإ
ن‍
‍ه‍
‍ا
ء
.
 
2
 
3
 
Every C++ must have 
main ( )
.
ي‍
‍ج‍
‍ب
 
أ
ن
 
ي‍
‍ك‍
‍و
ن
 
ك‍
‍ل
 
C
 
+
+
 
ا
ل‍
‍ر
ئ‍
‍ي‍
‍س‍
‍ي
 
(
)
.
{ 
open braces, indicates beginning of
body.
{
 
ا
لأ
ق‍
‍و
ا
س
 
ا
ل‍
‍م‍
‍ف‍
‍ت‍
‍و
ح‍
‍ة
،
 
ي‍
‍ش‍
‍ي‍
‍ر
 
ب‍
‍د
ا
ي‍
‍ة
 
م‍
‍ن
 
ا
ل‍
‍ج‍
‍س‍
‍م
.
}
 closing braces, indicates ending of
body.
}
 
ا
لأ
ق‍
‍و
ا
س
 
ا
ل‍
‍خ‍
‍ت‍
‍ا
م
،
 
ي‍
‍ش‍
‍ي‍
‍ر
 
ت‍
‍ن‍
‍ت‍
‍ه‍
‍ي
 
م‍
‍ن
 
ا
ل‍
‍ج‍
‍س‍
‍م
 
.
.
 
4
 
cout
 :- this statement is used to print the string
enclosed in quotation.
ا
لا
ح‍
‍ص‍
‍ا
ء
:
 
-
 
ي‍
‍س‍
‍ت‍
‍خ‍
‍د
م
 
ه‍
‍ذ
ا
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن
 
ل‍
‍ط‍
‍ب‍
‍ا
ع‍
‍ة
 
س‍
‍ل‍
‍س‍
‍ل‍
‍ة
 
ا
ل‍
‍م‍
‍غ‍
‍ل‍
‍ق‍
‍ة
 
ف‍
‍ي
ا
لا
ق‍
‍ت‍
‍ب‍
‍ا
س
.
It is also used to print the value of the variable.
ك‍
‍م‍
‍ا
 
ا
ن‍
‍ه‍
‍ا
 
ت‍
‍س‍
‍ت‍
‍خ‍
‍د
م
 
ل‍
‍ط‍
‍ب‍
‍ا
ع‍
‍ة
 
ق‍
‍ي‍
‍م‍
‍ة
 
ا
ل‍
‍م‍
‍ت‍
‍غ‍
‍ي‍
‍ر
.
Example:
cout<<” welcome to computer center “;
 cout<<”variable names”;
The(<<)operator called insertion operator.
د
ع‍
‍ا
 
ا
ل‍
‍م‍
‍ش‍
‍غ‍
‍ل
 
(
<
<
)
 
م‍
‍ش‍
‍غ‍
‍ل
 
ا
لإ
د
ر
ا
ج
.
 
5
 
cin: -
cin is used for inputting the
value of variable…
س‍
‍ي‍
‍ن
:
 
ي‍
‍س‍
‍ت‍
‍خ‍
‍د
م
 
-
c
i
n
 
لإ
د
خ‍
‍ا
ل
 
ق‍
‍ي‍
‍م‍
‍ة
 
ا
ل‍
‍م‍
‍ت‍
‍غ‍
‍ي‍
‍ر
Example :-cin>> a; , cin>> b;
cin>> a >>b ;
 The operator >> is known as
extraction operator, it extract the
value.
ا
ل‍
‍م‍
‍ش‍
‍غ‍
‍ل
 
>
>
 
ك‍
‍م‍
‍ا
 
ه‍
‍و
 
م‍
‍ع‍
‍ر
و
ف
 
ا
ل‍
‍م‍
‍ش‍
‍غ‍
‍ل
 
ا
س‍
‍ت‍
‍خ‍
‍ر
ا
ج
،
و
ا
س‍
‍ت‍
‍خ‍
‍ر
ا
ج
 
ا
ل‍
‍ق‍
‍ي‍
‍م‍
‍ة
.
 
6
 
Semicolons & Blocks in C++
منقوطة وكتل في 
C ++
In C++, the semicolon is a statement terminator.
م‍
‍ن‍
‍ق‍
‍و
ط‍
‍ة
 
و
ك‍
‍ت‍
‍ل
 
ف‍
‍ي
 
C
 
+
+
؟
 
ف‍
‍ي
 
C
 
+
+
،
 
ا
ل‍
‍ف‍
‍ا
ص‍
‍ل‍
‍ة
 
ا
ل‍
‍م‍
‍ن‍
‍ق‍
‍و
ط‍
‍ة
 
ه‍
‍و
 
ف‍
‍ا
ص‍
‍ل
 
ب‍
‍ي‍
‍ا
ن
.
That is, each individual statement must be ended with a
semicolon.
و
ه‍
‍ذ
ا
 
ه‍
‍و
،
 
ي‍
‍ج‍
‍ب
 
أ
ن
 
ت‍
‍ن‍
‍ت‍
‍ه‍
‍ي
 
ك‍
‍ل
 
ف‍
‍ر
د
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن
؟
 
ب‍
‍ف‍
‍ا
ص‍
‍ل‍
‍ة
 
م‍
‍ن‍
‍ق‍
‍و
ط‍
‍ة
.
F
o
r
 
e
x
a
m
p
l
e
,
 
f
o
l
l
o
w
i
n
g
 
a
r
e
 
t
h
r
e
e
 
d
i
f
f
e
r
e
n
t
 
s
t
a
t
e
m
e
n
t
s
:
؟
 
ع‍
‍ل‍
‍ى
 
س‍
‍ب‍
‍ي‍
‍ل
 
ا
ل‍
‍م‍
‍ث‍
‍ا
ل
،
 
ف‍
‍ي‍
‍م‍
‍ا
 
ي‍
‍ل‍
‍ي
 
ث‍
‍لا
ث‍
‍ة
 
ب‍
‍ي‍
‍ا
ن‍
‍ا
ت
 
م‍
‍خ‍
‍ت‍
‍ل‍
‍ف‍
‍ة
:
x = y;
y = y+1;
add(x, y);
 
7
 
A block is a set of logically connected statements that are
surrounded by opening and closing braces.
 
ك‍
‍ت‍
‍ل‍
‍ة
 
ع‍
‍ب‍
‍ا
ر
ة
 
ع‍
‍ن
 
م‍
‍ج‍
‍م‍
‍و
ع‍
‍ة
 
م‍
‍ن
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن‍
‍ا
ت
 
م‍
‍ن‍
‍ط‍
‍ق‍
‍ي‍
‍ا
 
ا
ل‍
‍م‍
‍ت‍
‍ص‍
‍ل‍
‍ة
 
ا
ل‍
‍ت‍
‍ي
 
ت‍
‍ح‍
‍ي‍
‍ط
 
ب‍
‍ه‍
‍ا
؟
 
ا
لا
ف‍
‍ت‍
‍ت‍
‍ا
ح
و
ا
ل‍
‍خ‍
‍ت‍
‍ا
م
 
ا
لأ
ق‍
‍و
ا
س
.
For example:
{
cout << "Hello World"; // prints Hello World
return 0;
}
C++ does not recognize the end of the line as a terminator.
For this reason, it does not matter where you put a
statement in a line.
ت‍
‍ع‍
‍ت‍
‍ر
ف
 
C
 
+
+
 
ن‍
‍ه‍
‍ا
ي‍
‍ة
 
ا
ل‍
‍س‍
‍ط‍
‍ر
 
ك‍
‍م‍
‍ا
 
ف‍
‍ا
ص‍
‍ل
.
 
ل‍
‍ه‍
‍ذ
ا
 
ا
ل‍
‍س‍
‍ب‍
‍ب
،
 
أ
ل‍
‍ي‍
‍س
 
ك‍
‍ذ
ل‍
‍ك
؟
 
لا
 
ي‍
‍ه‍
‍م
 
أ
ي‍
‍ن
ك‍
‍ن‍
‍ت
 
و
ض‍
‍ع‍
‍ت
 
ب‍
‍ي‍
‍ا
ن‍
‍ا
 
ف‍
‍ي
 
خ‍
‍ط
.
 
 
8
 
For example:
x = y;
y = y+1;
add(x, y);
is the same as
x = y; y = y+1; add(x, y);
 
9
 
Whitespace in C++
بيضاء في 
C ++
A line containing only whitespace, with a
comment, is known as a blank
line, and C++ compiler totally ignores it.
 
؟
 
و
ا
ل‍
‍س‍
‍ط‍
‍ر
 
ا
ل‍
‍ذ
ي
 
ي‍
‍ح‍
‍ت‍
‍و
ي
 
ف‍
‍ق‍
‍ط
 
ع‍
‍ل‍
‍ى
 
م‍
‍س‍
‍ا
ح‍
‍ا
ت
،
 
م‍
‍ع
 
ت‍
‍ع‍
‍ل‍
‍ي‍
‍ق
،
 
ك‍
‍م‍
‍ا
 
ه‍
‍و
م‍
‍ع‍
‍ر
و
ف
 
ف‍
‍ا
ر
غ
؟
 
ا
ل‍
‍خ‍
‍ط
،
 
و
C
 
+
+
 
م‍
‍ت‍
‍ر
ج‍
‍م
 
ي‍
‍ت‍
‍ج‍
‍ا
ه‍
‍ل
 
ت‍
‍م‍
‍ا
م‍
‍ا
.
؟
Whitespace is the term used in C++ to describe
blanks, tabs, newline characters
and comments.
ب‍
‍ي‍
‍ض‍
‍ا
ء
 
ه‍
‍و
 
م‍
‍ص‍
‍ط‍
‍ل‍
‍ح
 
ي‍
‍س‍
‍ت‍
‍خ‍
‍د
م
 
ف‍
‍ي
 
C
 
+
+
 
ل‍
‍و
ص‍
‍ف
 
ا
ل‍
‍ف‍
‍ر
ا
غ‍
‍ا
ت
،
 
ع‍
‍لا
م‍
‍ا
ت
،
أ
ح‍
‍ر
ف
 
ا
ل‍
‍س‍
‍ط‍
‍ر
؟
 
و
ا
ل‍
‍ت‍
‍ع‍
‍ل‍
‍ي‍
‍ق‍
‍ا
ت
.
 
10
 
Whitespace separates one part of a statement from
another and enables the compiler to identify where one
element in a statement, such as int, ends and the next
element begins.
ب‍
‍ي‍
‍ض‍
‍ا
ء
 
ي‍
‍ف‍
‍ص‍
‍ل
 
ج‍
‍ز
ء
 
و
ا
ح‍
‍د
 
م‍
‍ن
 
ب‍
‍ي‍
‍ا
ن
 
م‍
‍ن
 
آ
خ‍
‍ر
 
و
ت‍
‍م‍
‍ك‍
‍ن
 
ا
ل‍
‍م‍
‍ت‍
‍ر
ج‍
‍م
 
ل‍
‍ت‍
‍ح‍
‍د
ي‍
‍د
 
أ
ي‍
‍ن
 
ع‍
‍ن‍
‍ص‍
‍ر
و
ا
ح‍
‍د
 
ف‍
‍ي
 
ب‍
‍ي‍
‍ا
ن
 
ل‍
‍ه‍
‍ا
،
 
م‍
‍ث‍
‍ل
 
ك‍
‍ث‍
‍ا
ف‍
‍ة
 
ا
ل‍
‍ع‍
‍م‍
‍ل‍
‍ي‍
‍ا
ت
،
؟
 
ي‍
‍ن‍
‍ت‍
‍ه‍
‍ي
 
و
ي‍
‍ب‍
‍د
أ
 
ا
ل‍
‍ع‍
‍ن‍
‍ص‍
‍ر
 
ا
ل‍
‍ت‍
‍ا
ل‍
‍ي
.
Statement 1:
int age;
In the above statement there must be at least one
whitespace character (usually a space) between int and age
for the compiler to be able to distinguish them.
ف‍
‍ي
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن
 
ا
ل‍
‍م‍
‍ذ
ك‍
‍و
ر
 
أ
ع‍
‍لا
ه
 
أ
ن
 
ي‍
‍ك‍
‍و
ن
 
ه‍
‍ن‍
‍ا
ك
 
و
ا
ح‍
‍د
 
ع‍
‍ل‍
‍ى
 
ا
لأ
ق‍
‍ل
 
ح‍
‍ر
ف
 
م‍
‍س‍
‍ا
ف‍
‍ة
 
ب‍
‍ي‍
‍ض‍
‍ا
ء
(
ع‍
‍ا
د
ة
 
م‍
‍س‍
‍ا
ف‍
‍ة
)
 
ب‍
‍ي‍
‍ن
 
ا
ل‍
‍ب‍
‍ا
ح‍
‍ث
 
و
ا
ل‍
‍ع‍
‍م‍
‍ر
 
ل‍
‍ل‍
‍م‍
‍ت‍
‍ر
ج‍
‍م
 
أ
ن
 
ي‍
‍ك‍
‍و
ن
 
ق‍
‍ا
د
ر
ا
 
ع‍
‍ل‍
‍ى
 
ا
ل‍
‍ت‍
‍م‍
‍ي‍
‍ي‍
‍ز
 
ب‍
‍ي‍
‍ن‍
‍ه‍
‍ا
.
 
11
 
Statement 2:
fruit = apples + oranges; // Get the total fruit
In the above statement 2, no whitespace characters
are necessary between fruit and =, or between = and
apples, although you are free to include some if you
wish for readability purpose.
ف‍
‍ي
 
ا
ل‍
‍ب‍
‍ي‍
‍ا
ن
 
2
 
أ
ع‍
‍لا
ه
،
 
ل‍
‍م
 
أ
ح‍
‍ر
ف
 
ا
ل‍
‍م‍
‍س‍
‍ا
ف‍
‍ا
ت
 
ا
ل‍
‍ب‍
‍ي‍
‍ض‍
‍ا
ء
 
ا
ل‍
‍ض‍
‍ر
و
ر
ي‍
‍ة
 
ب‍
‍ي‍
‍ن
 
ا
ل‍
‍ف‍
‍و
ا
ك‍
‍ه
و
=
،
 
أ
و
 
ب‍
‍ي‍
‍ن
 
=
 
و
ا
ل‍
‍ت‍
‍ف‍
‍ا
ح
،
 
ع‍
‍ل‍
‍ى
 
ا
ل‍
‍ر
غ‍
‍م
 
م‍
‍ن
 
أ
ن‍
‍ت
 
ح‍
‍ر
 
ل‍
‍ت‍
‍ش‍
‍م‍
‍ل
 
ب‍
‍ع‍
‍ض
 
إ
ذ
ا
 
ك‍
‍ن‍
‍ت
ت‍
‍ر
غ‍
‍ب
 
ل‍
‍غ‍
‍ر
ض
 
ا
ل‍
‍ق‍
‍ر
ا
ء
ة
.
 
12
 
Comments in C++
تعليقات في 
C ++
Program comments are explanatory statements that you
can include in the C++
code.
تعليقات البرنامج هي البيانات الإيضاحية التي يمكن أن تدرج في 
C ++؟
التعليمات البرمجية.
 
These comments help anyone reading the source code.
هذه التعليقات تساعد أي شخص يقرأ شفرة المصدر.
All programming languages allow for some form of
comments.
جميع لغات البرمجة تسمح لبعض شكل تعليقات.
 
13
 
C++ supports single-line and multi-line comments.
؟ C ++ 
يدعم خط واحد وتعليق متعدد الخطوط.
 
All characters available inside any comment are
ignored by C++ compiler.
يتم تجاهل كافة الأحرف المتاحة داخل أي تعليق من قبل مترجم 
C ++.
C++ comments start with /* and end with */. For
example:
//* This is a comment *//
//* C++ comments can also*//
//* span multiple lines*//
Slide Note
Embed
Share

In this lecture by Mrs. Afreen Mukhtar Solkar, fundamental concepts of C++ programming are introduced. Topics covered include C++ statements, the main function, input/output operations using cout and cin, semicolons and blocks in C++, and the significance of whitespace in code formatting. The lecture emphasizes the importance of syntax and structure in C++ programming.

  • C++
  • Programming basics
  • C++ statements
  • Input/output operations

Uploaded on Sep 23, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. LECTURE-2 By: Mrs. Afreen Mukhtar Solkar 1

  2. cout<<Hello World; This line is a C++ statement. It is the statement that produce some effect in the program. C . ++ . The statement always ends with a semi colon (;). ( .) This character is used to mark the end of the statement. . return 0; The return statement causes the main function to finish. . 2

  3. Every C++ must have main ( ). .)( { open braces, indicates beginning of body. . } closing braces, indicates ending of body. .. C ++ { } 3

  4. cout :- this statement is used to print the string enclosed in quotation. : - . It is also used to print the value of the variable. . Example: cout<< welcome to computer center ; cout<< variable names ; The(<<)operator called insertion operator. . ) << ( 4

  5. cin: -cin is used for inputting the value of variable Example :-cin>> a; , cin>> b; cin>> a >>b ; The operator >> is known as extraction operator, it extract the value. cin - : >> . 5

  6. Semicolons & Blocks in C++ C ++ In C++, the semicolon is a statement terminator. . That is, each individual statement must be ended with a semicolon. . C ++ C ++ For example, following are three different statements: : x = y; y = y+1; add(x, y); 6

  7. A block is a set of logically connected statements that are surrounded by opening and closing braces. . For example: { cout << "Hello World"; // prints Hello World return 0; } C++ does not recognize the end of the line as a terminator. For this reason, it does not matter where you put a statement in a line. . C ++ . 7

  8. For example: x = y; y = y+1; add(x, y); is the same as x = y; y = y+1; add(x, y); 8

  9. Whitespace in C++ C ++ A line containing only whitespace, with a comment, is known as a blank line, and C++ compiler totally ignores it. . Whitespace is the term used in C++ to describe blanks, tabs, newline characters and comments. C ++ C ++ . 9

  10. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. . Statement 1: int age; In the above statement there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. . ) ( 10

  11. Statement 2: fruit = apples + oranges; // Get the total fruit In the above statement 2, no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose. 2 = = . 11

  12. Comments in C++ C ++ Program comments are explanatory statements that you can include in the C++ code. C ++ . These comments help anyone reading the source code. . All programming languages allow for some form of comments. . 12

  13. C++ supports single-line and multi-line comments. C ++ . All characters available inside any comment are ignored by C++ compiler. C ++. C++ comments start with /* and end with */. For example: //* This is a comment *// //* C++ comments can also*// //* span multiple lines*// 13

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#