-
The Attendance is quite important for me, because ut shows how you are committed and discipline towards the course & of course because are labs depends on each other which means that being an absent in one lab will definitely affect the understanding of the other one. Also, it will hugely affect your grades in the final project/practical, for example if you attended most of our labs, but you got 12/15 in the final project, I will raise you to 15.
I think know you realized how important it is LOL.
VIP Note
: attending less than 50% of the labs will mean that you will not have a final project,Be Caruful
-
I want from you all to Create accounts on:
- GitHub
Dont forget to follow me :)
- Codeforces
- HackerRank We will solve some problem on them
-
For each lab you will have 2 things, the lab recorded on YouTube & a documentation on GitHub (Just like what you are reading)
-
Programming is like going to the gym, imagine you have a championship about bodybuilding, and you have months to practice, it doesn't make any sense to what all 89 days and then in the day before the championship you decided to go to the gym and workout for 6 continues hours, this is not gonna work AT ALL, the same is applied to the programming you have to practice at least 2 hours each week + attending the lecture & the lab each week, so that your brain become familiar with the syntax and reading/writing code & most important to learn how to think and how to convert your ideas into working code
-
Programming is 99% logic, 1% memorizing the syntax. We are not going to memorize a dozen of chapters or pages that you have to memorize in order to solve the final exam, this is not the programming at all, it all depends on logic & PRACTICING
-
Your life in the tech field depends on your programming level, this is a fact that you gonna realize later
-
For each lab, there will be an assignment to practice
^-^
- From my point of view (which depends on the market & the field), the most important courses you will take in the college are (ranked from the most to the least):
- Programming X (X means Programming 1/2/3)
- Database X (X means 1/2)
- Operating System X (X Means 1/2)
- Network X (X means Network 1/2)
- Data Security (System Security)
- System Analysis
- These courses are the fundamental of information technology & software engineering fields,
so that you have to study them well, not just to get an
A+
in the course, but to finish the course with maximum benefits from them
- If I told you to define the Computer (programming) to a child, that will you say??
- Simply, programming is typing some words (statements) that are understandable by the machine (computer) to perform some task (solve a problem) instead of me (as a human being)
- This is the easiest & most forward definition of programming
- Or we can say in other word, what is the properties or the advantage of the programming (computer) compared to us as humans
- There are 4 main advantage of the computer:
Speed
: if I told you to play with me a gain, if I told you to calculate in your mind the summation of numbers from1 to 5
then you will think for a while then you wil answer with15
, but if i told you to get the summation this time from1 to 1,000,000
, then you will be shocked. When you learn how to code we will write this simple program to calculate the summation from 1 to N, the computer you will see will calculate it in a blank, but you have to note that the computer is not smart like us, it just executes the commands we till him, not more not less, if your commands are logically right then the output will be right otherwise don't expect a desired outputError Ratio
: We as humans may be exhausted, tired, not in a good mood, having problems in our live, not sleeping well, all the previous examples can cause the human to make error(s) or mistake(s) while performing a task, unlike humans the computer does not cause eny errors, to be more specific in the previous example (calculate numbers from1 to N
) you have the same statements (code) and you entered number5
, the output each time will be15
, it cannot be 16 in the tenth attempt. Imagine you are trying to log in your facebook account, can you login if you entered a password wrong, can the server makes a mistake and pass you, this is a fatal problem, so it cannot be happenedAvailability
: If I told you to solve mathematical problems for 1 hour directly, you will not have any problem, but if I told you to solve problems for 12 hours, you will call me a mad person, that's because we humans cannot work continuously for many hours directly. However, The server (huge computer) can work 24 hours a day, 7 days a week. BrieflyServer-Client
means that for example whenever you want to view for example your profile on facebook, you send arequest
to the facebook server telling him you want to view (access) this page, the facebook check that you have the authority view this resource, and if so it will perform anSQL
query to get your data something like this :SELECT * FROM users WHERE ID = YourFaceBookID
, then the result query will be sent to you back as aresponse
. This means that it can serve anyone at anytimeConcurrency
: We as humans can perform one task at a single time,it is impossible to read a book while cooking or study will watch a movie, out brain is designed to concentrate on only on thing , this is for humans while machines (computer) can perform many tasks (commands) at the same time, this concept is calledconcurrency
ormultithreading
. Regard the above example, the facebook server serve billions of users or as we said above (requests
) each second.
- During the World War II(1939-1945), the nazis was having the advantage & the upper hand for many reasons, but one of the most important & critical one
is that all of their radio messages that are sent to the soldiers in the battlefield was
Encrypted
, this means that if the message (Plaintext
is the readable text by human) ishi
the message sent in the radio will be for examplezl
(this is called the Ciphertext which is the plaintext after encryption), so even if the allies can interpret radio waves (messages), they cannot understand anything. In this time a Mathematician calledAlan Turing
with his team was trying to invent a machine that can break the cryptography of the enigma machine (machine used by nazis to encrypt text), they succeeded to build a machine calledBombe
(refers to a device that British cryptologists used to decipher encrypted German military communications during World War II). This machine was able to use logic to decipher the encrypted messages produced by the Enigma. experts assume that is invention has shortened length of the ware for at least 5 years,Alan Turing
was the godfather of computers nowadays - then after a device called
vacuum tube
was the fundamental unit of first generation of the computer (when the computer size was enormous that occupies a whole room) , it acts as aswitch
which means that it can turn on/off current (1
/0
statues), and using logic gates it was used to process simple instructions, but the problem with it is that it was huge, easily heated, damaged easily & of course slow
- In the current era, the fundamental unit of the computer's processor is
Transistor
which is a semiconductor device for amplifying, controlling, and generating electrical signals - A single processor (
CPU
) contains billions of transistors that process & executes instructions
Billions Of Transistors Inside A CPU
- The Main 3 Hardware components are
CPU
,RAM
&Hard Disk
,they are connected to each other by the help ofMotherboard
- When you as a user click on
Word
program, word program data is stored permanently onHard Disk
(assume word is 10GB storage inHDD
), permanently means that is the current is off from your computer, your data will still be stored (Also Can be called Nonvolatile). When you click on the program, main statements that must be executed in order for the program to run will be copied fromHard Disk
toRAM
, TheRAM
is a temporally (volatile) memory which means that when you turned of the PC of the current is off, all the data inside it will be vanished. let's assume that from10GB
of word only2GB
will be copied to theRAM
, now theRAM
will send these instructions to theCPU
which will process the instruction that will be sent again to theRAM
to be temporarily stored, if a data inside theRAM
should be stored permanently then it will be copied fromRAM
toHard Disk
, and when toy close the program the data of that program will be removed from theRAM
- The logical question here is why do
RAM
exists, why CPU not interacting directly withHDD
?! - The problem here is that the
CPU
is so fast while theHDD
is so slow. When a fast hardware component interacts with other slow components, the fast component will decrease its speed to be compatible with the slower component, this phenomenon is calledbottleneck
. This means no matter the speed of theCPU
it will be, we won't be able to utilize this speed no matter what, so that theRAM
was invented as it is way faster than theHDD
& at the same type has an enough space (4-32GB) not likeCPU
's cache which might be only8MB
- The most important part for programmers among the above three parts, can you guess ?!
- The
RAM
is the most important part for the programmers, there is an advanced branch in computer science calledData Structure
Data Structure
: is a branch inCS
that is concerned with storing & organizing the data in theRAM
, it is considered to be one of the main topics the professional programmer must know- When a program is slow/crashes/consume a lot of memory, one of the most important reason for all of the above problem is that the programmer who wrote the code has used the wrong
Data Structure
(or not using it at all) - Let's observe the Logical Structure of the RAM from the following Diagram:
- As we can see above there is
4
main sections in theRAM
:
Code Section
: In this section, source code of your file (*.cpp
/*.java
/*.php
) exists + machine code (binary code which is understandable by theCPU
*
)Static
/Global
Variables: We will understand the meaning of the wordStatic
in the future inOOP
, while the wordGlobal
will understand in this LabStack
: The part that stores the executedMain()
Function or any other Function(s), will discuss it laterHeap
: We can access this section indirectly usingPointers
,we will discuss about them later
*
The compiler is the software that is written by the creator of a Programming Language, it's job
is to convert your code (that is written in English) to Binary (1
/0
) to be executed by the processor
- You have to know the following critical point, if you have learned a programming language deeply, deeply means you have practice with it or you have solved problems using it or even worked on projects. Then I want to congratulate you because you have learned almost all other language
- This is because all programming languages have the same Concepts, or it can be called
Principles
- All Programming Languages contains Topics like:
Variables
Data Types
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Conditions
Loops
Functions
Arrays
Input
/Output
Object Oriented Programming (OOP)
(Programming 2 Main Topic)
- They only differ in the
Syntax
,Syntax
means the way of writing the code so that thecompiler
can understand what you are typing to be able to convert it into binary - So the bottom line, all programming languages have the same
Principles
but differSyntax
- Now Let's type the normal structure of a
C++
program to print a message in the terminal (black screen where we run our program in)
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}
iostream
: A library used to be able to use Input/Output inC++
(cin
&cout
)using namespace std;
: used to specify our scope is standard namespace inc++
, you can run your program without this line, but you have to writestd::
aftercout
/cin
/string
/endl
and so on, something like thisstd::cout<<"Hello World";
int main()
: it is the entry point when you run a program (the part which will be executed by the controller duringrun time
)
Variables
: They are block or chamber reserved by the compiler in the main memory (RAM
), used to store a value that will be used & retrieved during the executing of the program.- For example if you are executing a program that calculate the age of a user in days, when the user enter a value (his age in years), you may want to perform any calculations with this value later, so that you store it in a variable
- Each variable must have 2 things, a
Data Type
& aName
-
Data types specify the value that will be stored in the variable
-
They include:
int
: Store whole numbers like1
,2
,3
, range up to10^9
, allocate only4
Bytesshort
: Likeint
but allocate only2
Bytes in the memory, range up to10^4
long
: Likeint
but allocate only8
Bytes in the memory, range up to10^18
float
: Store decimal numbers like3.14
, range up to10^9
, allocate only4
Bytesdouble
: Likefloat
but allocate only8
Bytes in the memory, range up to10^18
char
: Store single character in single quotes like'm'
/'f'
, allocates1
Bytesstring
: Store Array of characters like"Ahmed Arafat"
, allocates32
Bytesbool
: store onlyTrue 1
orFalse 0
, allocates1
Byte
-
Let's see this sample of code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
short num1 = 10;
int num2 = 1000000;
long num3 = 10000000000;
float num4 = 3.14;
double num5 = 3.14;
char c = 'm';
string str = "Ahmed Arafat";
bool is_male = 1;
}
- There are some rules that must be followed while naming a variable
- Use one of the following characters:
a
toz
A
toZ
0
to9
(numbers)underscore
(_
used instead of space)
- Don't start the name of the variable with a number,
int 1x;
is wrong whileint x1;
is correct
This is because thePhysical Structure of The RAM
is that it consists of many blocks each block is1 Btyes
& the most important part is that this block is Addressable (Has a physical address), this address is in hexadecimal number (from0
to9
& fromA
toF
).
When you create a variable like thisint x;
, the compiler will then store this name in a table in which refers to an address (something like0F200
), so thenx -> 0F200
. When you typecout<<x;
, the compiler will go to the table and see which address this variable name refers to, and then it will print the value stored in it
The problem here is that when you have a variable with name1x
, then in that table1x -> 0F200
. When you typecout<<1x;
, the compiler will not understand whether1x
is the variable name or the address, so to prevent this ambiguity we cannot start a variable name with a number - Don't name a variable with
Keywords
*
: likefor
/while
/int
/using
/namesapce
/do
/if
/else
/break
/continue
/switch
/class
and so on
- Use one of the following characters:
*Keywords
: is a predefined or reserved word in C++ library with a fixed meaning and used to perform an internal operation. C++ Language supports more than 64 keywords.
- Don't Forget The Following :
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;// Declaration
int y = 10;// Initialization
}
-
In Codeblocks, when I press
f9
button, the compiler first compile the file, this means that it will check each line to make sure that it can understand what you have typed , in other word it checks theSyntax
, if there is anything wrong in it will then till you the line that contains the problem -
This phase or time is called
Compile Time
orCompilation Time
-
After checking of the syntax by the compiler, the program will be now executed and then will be transformed from compile time to run time (executing)
-
Here are some examples of syntax error (compilation error):
include <bits/stdc++.h>
using namespace std;
int main()
{
int x;// Declaration
int y = 10;// Initialization
}
O/P
: Error at line#1
, expected#
sign
- Another example:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x // Declaration
int y = 10;// Initialization
}
O/P
: Error at line#6
, expect;
at end of the line
- I prefer to watch the Lab rather than typing this part because it needs
a whiteboard to explain it accurately, so please check the last part
of
Lab #1
on YouTube.