Advanced Programming Concepts 2025
Advanced Programming Concepts 2025
2025
syntax
code
set of rules defines the correct sequence of symbols that can be used to form a correctly structured
program.
The cout object, together with the << operator, is // Example of cout usage
used to output values/print. #include
int main() {
cout << Output
settings
print
operator cout << "Hello World!";
compare_arrows
Standard Display values
output stream Insertion return 0;
operator
}
code
Represent non-printable or special
characters
\n line feed - new line
subdirectory_arrow_right
\t horizontal tab Formatting
keyboard_tab
format_align_left
Control text layout and appearance
\a audible bell
volume_up
\\
backslash backslash
String Literals
text_format
Used within quoted strings
\" double quote
format_quote
// Example using escape sequences
cout "Hello\nWorld!\tWelcome to C++\nThis is a \"quote\"";
/* Comments */
Essential for code documentation and improving readability
Single-line comment
Begins with // and continues to the end of the line /* This is a multi-line comment
short_text
that spans across multiple
Multi-line comment
lines of code */
Begins with /* and ends with */
subject
cout << "Hello World"; // Output text
format_quote
Data Variable Optional data_type variable_name;
Type Name Value data_type variable_name =
category
label
assignment
Specifies what Identifier used Initial value
kind of data to reference can be
initial_value;
the variable the variable assigned at
will hold declaration
arrow_forward
Initial value After reassignment
text_format
check_box
double_arrow
Sequence of characters used to Stores true or false values Double precision floating point number
represent text
bool isPassed = true; double price = 19.99;
string name = "John";
lightbulb
short_text
It is recommended to use descriptive names in order
int c = a + b;
x y i j to create understandable and maintainable code
label
label
label
label
// More readable code with descriptive
Descriptive names
names
description
age sum totalVolume int age = 25;
label
label
label
int yearsOfService = 30;
studentCount int totalExperience = age + yearsOfService;
label
Unique Descriptive Maintainable
fingerprint
description
build
Each identifier must be unique within Clear names improve code readability Good identifiers make code easier to
its scope maintain
Names can contain letters, digits and underscores Valid Variable Names
text_format
check_circle
int age;
Names must begin with a letter or an underscore (_) string student_name;
play_arrow
double _totalAmount;
int MAX_VALUE;
Names are case sensitive (myVar and myvar are different float accountBalance1;
text_fields
variables)
cancel
block
int 2ndPlace;
%, etc.
string student name;
double total#Amount;
Reserved words (like C++ keywords, such as int) cannot be used int int;
gpp_bad
as names float account-balance;
block
Reserved words cannot be used as
bool void if else variable names
Language Syntax
case break continue return
code
Keywords form the core syntax of the
language
class struct public private
error
Using reserved words causes code to
Important Note fail
warning
Using reserved words as identifiers will result in compilation errors. Always choose names that are not part of the C++ language
keywords.
Using the const keyword will declare the variable const int PI = 3.14159;
as "constant", which means unchangeable and
read-only. // This will cause an error:
PI = 4; // Cannot modify a constant
Immutable Read- Safety
lock
security
Only
visibility
Value cannot Prevents const
be modified Can be accidental int
after value changes PI
lock
accessed but
declaration not changed
3.14159
arrow_forward
keyboard
Advanced Programming | 2025 | Ahmed Awad 21
code
Example
Sample Output
name, age
Enter your name: John
Enter your age: 25 string, int
X = 10 , Y = 5
Addition
info
add_circle
Combines two values into a sum
Operator Description Example
remove_circle
- Subtracts second value from first value Sub = X – Y //Sub = 5 Finds the difference between values
percent
% Returns the division remainder Mod = X % Y //Mod = 0 Returns remainder after division
Addition
int x = 10; int y = 5; int result;
add_circle
Combines values using + operator
// Addition result = x + y; cout << "x + y = " << result << endl;
Subtraction
remove_circle
Finds difference using - operator
// Subtraction result = x - y; cout << "x - y = " << result << endl;
// Multiplication result = x * y; cout << "x * y = " << result << endl; Multiplication
close
Calculates product using * operator
Output
terminal
x + y = 15
x - y = 5
x * y = 50
assignment
1 Basic Arithmetic
Write a program that takes two numbers as input and performs all arithmetic operations (+, -, *, /, %) on them.
2 Area Calculator
Create a program that calculates the area of a rectangle using user-provided length and width values.
3 Temperature Conversion
Write a program that converts Celsius to Fahrenheit using the formula: F = (C × 9/5) + 32.
X = 10
X = X + 1 //X =
info
++ ++X
11
-= X -= Y X = X - Y //X = 5
X = 10 , Y = 5
info
*= X *= Y X = X * Y //X = 50
autorenew
// Same as: x = x + y // Same as: num = num * factor Performs operation and assignment in
// Result: x = 15 // Result: num = 21 one step
Readability
Subtraction Assignment Modulo Assignment
code
remove_circle
percent
Makes code more readable and
int a = 20; int value = 17; maintainable
int b = 8; int divisor = 5;
Given a = 15 and b = 20, evaluate the following expressions: Write a program that takes two numbers as input and displays which one is greater or if they are equal.
Logical Z = !X //Z
AND OR NOT ! !X
= 0
NOT
add_circle
call_split
not_interested
True only if True if at least Reverses the
both operands one operand logical state
are true is true
help_outline
instructions if that condition is met.
call_split
call_made
call_received
fork_right
swap_horiz
Decision Logic Branching Execute Instructions - Run the appropriate code
block
rule
alt_route
Making
play_arrow
check_circle
Evaluate Execute
Control expressions as different code
program flow true or false paths
Continue Flow - Resume normal program
based on
conditions execution
merge_type
Advanced Programming | 2025 | Ahmed Awad 37
IF Statement
call_made
The if statement is used to execute a block of code
only if a specified condition is true.
terminal
You are eligible to vote.
code
Condition is True - Execute code in the if block
if (condition) {
check_circle
// code to execute if condition
is true
Condition is False - Execute code in the else block
} else {
cancel
// code to execute if condition
Two Complete Control is false
all_inclusive
Paths Flow
call_split
alt_route
Covers all }
Provides possible Directs
alternative outcomes program
execution based on
path condition
terminal
You are not eligible to vote yet.
code
conditions in sequence, executing the code block
if (condition1) {
for the first condition that evaluates to true.
// code if condition1 is true
} else if (condition2) {
First condition - Checked first, executes if true // code if condition2 is true
looks_one
} else {
// code if all conditions are false
Additional conditions - Checked in sequence if previous }
are false
looks_two
Multiple Priority Flexibility
Final else - Executes if all conditions are false
priority_high
alt_route
Checks
layers
First true Handle
looks_3
Test several condition multiple
conditions in executes scenarios
order efficiently
terminal
order efficiently Grade: B
code
called a case, and the variable being switched on is
checked for each case. switch (expression) {
case constant1:
Multiple Values - Efficiency - Often // code to execute
Test against multiple faster than if-else
cases chains
break;
check_circle
speed
case constant2:
Equality - Only
Default - Optional // code to execute
default case for no
checks for equality break;
match
rule
all_inclusive
default:
// code if no case matches
Alternative Cases Branching
alt_route
format_list_numbered
call_split
Alternative to Test variable Execute code }
multiple if- against based on
else specific values matched case
statements
Output
terminal
Good!
play_arrow
repeat
sync
update
Check Condition - Determine if loop should
For Loop While Loop Do-While continue
help_outline
Executes a Executes while Loop
specific number condition is true Executes at least
of times once, then
Execute Statements - Run code inside the loop
checks condition
code
Repetition Condition Efficiency Update - Modify loop variables
repeat
rule
speed
update
Execute code Controls when Reduces code
multiple times loop duplication
terminates
code
Initialization - Sets Condition - Tested
up loop counter before each iteration for (initialization; condition;
filter_1
filter_2
increment) {
Increment - Updates Body - Code
counter after each executed in each // code to be executed
iteration iteration
filter_3
code
}
Initialize - Set counter to starting value cout << i << " ";
filter_1
}
code
Condition Check - Loop Body - while (condition) {
Tested before each Executed when
iteration condition is true
// code to be executed
help_outline
code
// as long as condition is true
Variable Update - Termination - Loop }
Must be updated ends when condition
inside the loop becomes false
update
block
Pre-test Flexible Caution
rule
repeat
warning
Condition Number of Risk of infinite
checked iterations not loops
before fixed
execution
int i = 1;
Check Condition - Evaluate before each iteration
help_outline
while (i <= 5) {
cout << i << " ";
Execute Code - Run statements if condition is true i++;
code
}
terminal
1 2 3 4 5
rule
repeat
warning
Condition Number of Risk of infinite
checked iterations not loops
before fixed
execution