0% found this document useful (0 votes)
76 views10 pages

C++ Programming: Academic Year 2018-2019 Lecturer Zanco A. Taha (MSC.)

1. The document outlines C++ programming lecture materials for the 2018-2019 academic year at Noble Institute's Computer Department, including flowcharts and algorithms for finding the area of a rectangle and finding the maximum of three numbers, as well as comments, variables, data types, and more. 2. It provides flowcharts and pseudocode algorithms to find the area of a rectangle by inputting length and width, and to find the maximum of three numbers A, B, and C. 3. The document also covers comments in C++, defining variables with valid identifiers, and fundamental data types including characters, integers, floating-point numbers, Booleans, and strings.

Uploaded by

Rahel Sabr
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
0% found this document useful (0 votes)
76 views10 pages

C++ Programming: Academic Year 2018-2019 Lecturer Zanco A. Taha (MSC.)

1. The document outlines C++ programming lecture materials for the 2018-2019 academic year at Noble Institute's Computer Department, including flowcharts and algorithms for finding the area of a rectangle and finding the maximum of three numbers, as well as comments, variables, data types, and more. 2. It provides flowcharts and pseudocode algorithms to find the area of a rectangle by inputting length and width, and to find the maximum of three numbers A, B, and C. 3. The document also covers comments in C++, defining variables with valid identifiers, and fundamental data types including characters, integers, floating-point numbers, Booleans, and strings.

Uploaded by

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

Ministry of Higher Education Computer Department

Noble Institute 1st Stage

C++ Programming
Academic Year
2018-2019

Lecturer
Zanco A. Taha (MSc.)
Lecture Outlines
1. Flowchart and Algorithm
2. Structure of C++ Program.

2
Flowchart for finding the area of a rectangle
Start

Input
Length

Input
Width

Area=Length * Width

Output
Area

End
3
Algorithm for finding the area of a rectangle
Input: Length and Width
Output: Area
#include <iostream>
Steps: Using namespacestd;
input Length Int main (){
input Width Int L,W,A;
Area = Length * Width Cin>>L>>W;
Output Area A=L*W;
Cout<<“Area=” <<A;
Return 0;
|
Flowchart for finding max of 3 numbers
Start

Input
A,B,C

Yes No Yes Yes Output


Output B>C A>B A>C
A
B

No No

Output
C

End
5
Algorithm for finding max of 3 numbers
Input: Three numbers A,B,C
Output: Max of numbers A,B,C
Steps:
input A,B,C
If A > B
If A > C
Output A
else
Output C
Else
If B > C
Output B
else
Output C
Comments
1- // line comment
2- /* block comment */

Example:
/* my second program in C++
with more comments */
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World! "; // prints Hello World!
cout << "I'm a C++ program"; // prints I'm a C++ program
return 0;
}
Variables and Types
• We can now define variable as a portion of memory to store a
value
• Each variable needs a name that identifies it and distinguishes it
from the others.
• The Name of variable (identifier) is a sequence of one or more
letters, digits, or underscore characters _.
• Spaces, punctuation marks, and symbols cannot be part of an
identifier. In addition, identifiers shall always begin with a letter.
• They shouldn’t be keywords like (cout,cin …etc).
• The C++ language is a "case sensitive" language.
Fundamental data types
• Character types: They can represent a single character, such as
'A' or '$'.
• Numerical integer types: They can store a whole number value,
such as 7 or 1024. They exist in a variety of sizes, and can either
be signed or unsigned.
• Floating-point types: They can represent real values, such as
3.14 or 0.01, with different levels of precision.

• Boolean type: The boolean type, known in C++ as bool, can


only represent one of two states, true or false.

• String: Variables of this type are able to store sequences of


characters, such as words or sentences
Fundamental data types

You might also like