BEGIN WITH C++
WHO ARE WE?
• Ahmed Farag Mohammed
• ahmed.farag1111@gmail.com
• Sara Tarek Ali
• eng.saratarek@gmail.com
Our target :
is to keep a smile on your face while learning new stuff ;)
NOW, WHO ARE YOU?!!
WHY DID YOU JOIN THIS COURSE?
Hwaay you do zes, hwaaay!!??
What is a Computer?
• A definition of a computer is an electronic
device that can input data, process data
and output data, accurately and at great
speed.
• Data are any kind of information that can
be codified in some manner (i.e. 0s , 1s)
and input into the computer.
What is a Computer? Cont.
Fast Device
with a sequence
of commands
mn el a5er!
Input output
Take 2 numbers
and add them
and output the
result
Example
7, 5 12
The Purpose of this course
Fast Device
with a sequence
of commands
Input output
our main concern through out this
course is to write the sequence of
commands that the computer will
perform in high speeds to solve certain
problems of our daily life.
Lets play a game
• Type the following instruction, and see
the magic happens ;)
cout << 6 + 7 ;
Congratulations
• You just created your first Computer
Program (Application) in 30 secs ;)
Now, let’s see how this happened
Starting for the very beginning :D
Stored Program Computer
• John Von Neumann (Dec. 28, 1903 – Feb.
8, 1957) {
Instruction 1
Instruction 2
Instruction 3
.
.
.
.
Instruction n
}
Program
Counter
How can the computer understand us?
• Those instructions that you saw
previously are translated to computer
language (binary [0,1]).
• There are two ways to translate a
program; Interpreting or Compiling.
Interpreter
• An interpreter is a program that reads a
high-level program and does what it says.
In effect, it translates the program line-
by-line, alternately reading lines and
carrying out commands.
Begin with c++ Fekra Course #1
Complier
• A compiler is a program that reads a high-
level program and translates it all at once,
before executing any of the commands.
• Often you compile the program as a
separate step, and then execute the
compiled code later. In this case, the high-
level program is called the source code,
and the translated program is called the
object code or the executable.
Begin with c++ Fekra Course #1
Primitives of Programming
Languages
Input Output Logic
Testing Repetition
Computers cannot Think.. People
can!
• Computers are merely machines, made of
silicon, iron, and other stuff.
• What mostly qualifies computers is their
Speed.
• A Pentium 4 computer (2 GHz), can do
addition of two numbers in 0.5 Nanosecond.
• Nanosecond is: ( 1/1,000,000,000 of a
second)
Thus, we have this rule..
• If you tell the computer to do something
stupid, the computer accurately and at
great speed does that stupid action!
• Your idea of a computer program not
working or making a mistake is likely
coming from this aspect.
Data
• Normally, we think of data as facts and
numbers such as a person’s name and
address or the quantity or cost of an item
purchased. However, data can also be
graphical images, sound files, movies and
more.Characters
ABC
Decimals
8.0023
Sounds Images
Integers
1234
Errors
• When a program has an error in it, that
error is often called a “bug.” And the
process of getting all of the errors out of a
program is called debugging.
• Funny story behind it :D
Programming Languages
Programming Languages
• The computer internally operates on the
binary number system. In the binary
number system, the only valid digits are 0s
and 1s.
• Electronic circuits can either have some
electricity in them or not. 1 means ON, and
0 means OFF.
• No one writes programs in binary, it’s very
tedious.
Begin with c++ Fekra Course #1
C++
• C++ is the programming language we will
learn in this course
• The instruction that you used at the
beginning of this session is actually C++
statement “cout << 6 + 7;”
I/O
• As we said, any program gets input from
user and has an output, so how can we
get input and return output ?
• Let’s see ;)
Output
cout
Data
>>
operator
Console output stream
Data
Computer Screen
Output examples
cout << “Hello World!!”;
cout << 3;
cout << “3”;
cout << 5 * 15;
cout << 15 / 5;
Input
• Let’s get input from user, But where we
will save this data ?!!
Variables
• Do you remember when we talked about
“Data” ?
• So, where it will be saved ?!
• We create variables to save data needed
through the program or in files to be
reused again and again (we will talk about
files later)
• Variables shouldn’t begin by a number,
and shouldn’t have any spaces
Data types
• Since the variable holds data, so this variable
should have a data type
• Data types in C++ :
– int integer number
– float float numbers
– double big numbers (int OR float)
– char characters
– Adding long more size for a variable
EX: long int
– bool return true or false
– string
Declaration and initialization
• int x;
– Here we say that we want to declare x as a
variable from the type int (integer)
• int x = 3;
– Here , x is declared as an integer and also
initialized by the value “3”
• Note: it is a better practice to initialize
your variables.
Back to I/O
• Now we can use these variables to take
data from the user.
• But how input actually works?
Input
cin
Variable
<<
operator
Console input stream
Data
Computer Screen
Contains the input Data
I/O cont’
• So now, let’s take input and save it in
avariable
• We will use cin object , very similar to
cout
• For example :
– Int x;
– cin>>x
• Here the value entered will be saved in
variable x
I/O example
int x;
cout<<“Enter a number: ”;
cin>>x;
cout << x + 5;
Try it ;)
I/O training
• Get Two numbers from the user and print
the result of multiplying them together.
Input:
3 4
Expected out from your program:
12
Answer
int num1;
int num2;
cin >> num1;
cin >> num2;
cout << num1 * num2;
Errors
• There is two types of errors
• Syntax : appears when you complie your
code (error & warning)
• Semantic (by logic) : appears when you
run your program and you don’t get the
desired output.
• Example if you made a program to devide
2 numbers and you gave it 5/0, this
wouldn’t give you the desired output.
Operators
 Now:
 * / + - %
 -- , ++ (before and after var)
 =
 Next sessions:
 ==, < , <= , > , >=
 || ,&& , >> , <<
 | , &
 ! , !=
Practice operators
Special characters
• a : make a sound when the program come
to it
• n : make a new line
• r : make the cursor goes to the beginning of
the line
• t : make the cursor leave to the next tab
• For example :
– Cout<<“n” ; <- prints a new line
– Cout<<“t”; <- prints a tab
• We have also ->  , ’ , ”
Practice special char.s
• cout << “line1nline2nline3”;
• cout << “row1-col1trow1-col2n”
<< “row2-col1trow2-col2n”;
• cout << “my name is “ahmed””;
• cout << “path is c:folderfile.exe”;
• cout << “maho enta aslan 3ayel teeta”
I have a little confession
I was hiding some code from you
Simple Program
# include <iostream>
using namespace std;
int main()
{
cout << “Hello World!!" ;
return 0;
}
C++ Program
• Wait wait wait a moment !!
• Where will I write my program ? O_o
IDE
• IDEs are programs that help us to write
new programs !!
• IDEs as : Eclipse, Netbeans, Visual Studio,
Dev C++ and others
• So let’s open our IDE and write a program
!
Libraries
# include <iostream>
using namespace std;
int main()
{
cout << “Hello World!!" ;
return 0;
}
Libraries cont.
• What are Libraries ?!
• Every thing should extend from a library
in C++ language
• We declare the library on this form
• #include< name of the library.h >
– <> : we should surrounded the library name
with this two brackets
– .h : the extension of the library
Namespace
# include <iostream>
using namespace std;
int main()
{
cout << “Hello World!!" ;
return 0;
}
Namespace cont.
• We always add the line “Using
namespace std;” at the beginning of the
program, what does it means ??
• Why namespaces are useful ?
Main
# include <iostream>
using namespace std;
int main()
{
cout << “Hello World!!" ;
return 0;
}
Main cont.
• In C++ any program should have a main from
which the program begin its work
int main(){
// our program
return 0;
}
• So soon we will know the meaning of each
part of these stuff !
• But for now we will write our program inside
the main
Simple Program
# include <iostream>
using namespace std;
int main()
{
cout << “Hello World!!" ;
return 0;
}
Let’s get interactive with users
# include <iostream>
using namespace std;
int main()
{
int num1, num2;
cout << “Enter first number: " ;
cin >> num1;
cout << “Enter second number: ”;
cin >> num2;
cout << num1 << “+” << num2 << “=“ << num1+num2;
return 0;
}
Notes for a good programmer
• Indentation !!!
• Variable names (naming ways)
• Variables are case sensitive
• Spaces and comments
• Comments types (// , /* */)
• initialize your variables
Training 1
• Write a program that takes your name
and say:
– Hello “somebody”
Training 2
• Write a program that takes from the user
two numbers and calculate:
– Sum
– Difference
– Multiplication
– Division

More Related Content

PPTX
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
PDF
Basic buffer overflow part1
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
PPT
Introduction to C
PDF
Writing Asynchronous Programs with Scala & Akka
PPTX
Microprocessor chapter 9 - assembly language programming
PDF
Runtime Bytecode Transformation for Smalltalk
PPT
SDD Translation
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Basic buffer overflow part1
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Introduction to C
Writing Asynchronous Programs with Scala & Akka
Microprocessor chapter 9 - assembly language programming
Runtime Bytecode Transformation for Smalltalk
SDD Translation

What's hot (13)

PDF
Dive into exploit development
PPTX
Intro to C++
PPT
Chapt 01 Assembly Language
PPTX
Introduction to Assembly Language Programming
PDF
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
PPTX
Programming
PPT
C++basics
PDF
SEH based buffer overflow vulnerability exploitation
PPTX
Assembly fundamentals
PDF
Unit i se pai_dos function calls
PPT
Introduction
PPTX
Intro to assembly language
Dive into exploit development
Intro to C++
Chapt 01 Assembly Language
Introduction to Assembly Language Programming
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
Programming
C++basics
SEH based buffer overflow vulnerability exploitation
Assembly fundamentals
Unit i se pai_dos function calls
Introduction
Intro to assembly language
Ad

Viewers also liked (6)

PPT
A Winning Package
PPT
Inheritance : Extending Classes
PDF
PHP Files: An Introduction
PPTX
Classes and objects
PPT
Functions in C++
PPTX
Slideshare ppt
A Winning Package
Inheritance : Extending Classes
PHP Files: An Introduction
Classes and objects
Functions in C++
Slideshare ppt
Ad

Similar to Begin with c++ Fekra Course #1 (20)

PPTX
Whole c++ lectures ITM1 Th
PPTX
Lecture 1 Introduction C++
PPT
Basic structure of C++ program
PDF
C++ advanced PPT.pdf
PPTX
C++ Introduction to basic C++ IN THIS YOU WOULD KHOW ABOUT BASIC C++
PPTX
KMK1093 CHAPTER 2.kkkpptx KMK1093 CHAPTER 2.kkkpptx
PPTX
Paksitan Zindabad in ITDevelopment of IT
PDF
4. programing 101
PPT
C++ for beginners
PPT
Lecture01
PDF
Basic Elements of C++
PPT
C PLUS PLUS FOR BS ELECTRICAL 2ND SEMSTERLecture01.ppt
PDF
Chap 2 c++
PPT
slidenotesece246jun2012-140803084954-phpapp01 (1).ppt
PPT
chapter-2.ppt
PPT
Introduction To Programming subject1.ppt
PPTX
computer ppt group22222222222222222222 (1).pptx
DOC
Class XII Computer Science Study Material
PPTX
C++ lecture 01
Whole c++ lectures ITM1 Th
Lecture 1 Introduction C++
Basic structure of C++ program
C++ advanced PPT.pdf
C++ Introduction to basic C++ IN THIS YOU WOULD KHOW ABOUT BASIC C++
KMK1093 CHAPTER 2.kkkpptx KMK1093 CHAPTER 2.kkkpptx
Paksitan Zindabad in ITDevelopment of IT
4. programing 101
C++ for beginners
Lecture01
Basic Elements of C++
C PLUS PLUS FOR BS ELECTRICAL 2ND SEMSTERLecture01.ppt
Chap 2 c++
slidenotesece246jun2012-140803084954-phpapp01 (1).ppt
chapter-2.ppt
Introduction To Programming subject1.ppt
computer ppt group22222222222222222222 (1).pptx
Class XII Computer Science Study Material
C++ lecture 01

Begin with c++ Fekra Course #1

  • 2. WHO ARE WE? • Ahmed Farag Mohammed • [email protected] • Sara Tarek Ali • [email protected] Our target : is to keep a smile on your face while learning new stuff ;)
  • 3. NOW, WHO ARE YOU?!!
  • 4. WHY DID YOU JOIN THIS COURSE? Hwaay you do zes, hwaaay!!??
  • 5. What is a Computer? • A definition of a computer is an electronic device that can input data, process data and output data, accurately and at great speed. • Data are any kind of information that can be codified in some manner (i.e. 0s , 1s) and input into the computer.
  • 6. What is a Computer? Cont. Fast Device with a sequence of commands mn el a5er! Input output Take 2 numbers and add them and output the result Example 7, 5 12
  • 7. The Purpose of this course Fast Device with a sequence of commands Input output our main concern through out this course is to write the sequence of commands that the computer will perform in high speeds to solve certain problems of our daily life.
  • 8. Lets play a game • Type the following instruction, and see the magic happens ;) cout << 6 + 7 ;
  • 9. Congratulations • You just created your first Computer Program (Application) in 30 secs ;)
  • 10. Now, let’s see how this happened Starting for the very beginning :D
  • 11. Stored Program Computer • John Von Neumann (Dec. 28, 1903 – Feb. 8, 1957) { Instruction 1 Instruction 2 Instruction 3 . . . . Instruction n } Program Counter
  • 12. How can the computer understand us? • Those instructions that you saw previously are translated to computer language (binary [0,1]). • There are two ways to translate a program; Interpreting or Compiling.
  • 13. Interpreter • An interpreter is a program that reads a high-level program and does what it says. In effect, it translates the program line- by-line, alternately reading lines and carrying out commands.
  • 15. Complier • A compiler is a program that reads a high- level program and translates it all at once, before executing any of the commands. • Often you compile the program as a separate step, and then execute the compiled code later. In this case, the high- level program is called the source code, and the translated program is called the object code or the executable.
  • 17. Primitives of Programming Languages Input Output Logic Testing Repetition
  • 18. Computers cannot Think.. People can! • Computers are merely machines, made of silicon, iron, and other stuff. • What mostly qualifies computers is their Speed. • A Pentium 4 computer (2 GHz), can do addition of two numbers in 0.5 Nanosecond. • Nanosecond is: ( 1/1,000,000,000 of a second)
  • 19. Thus, we have this rule.. • If you tell the computer to do something stupid, the computer accurately and at great speed does that stupid action! • Your idea of a computer program not working or making a mistake is likely coming from this aspect.
  • 20. Data • Normally, we think of data as facts and numbers such as a person’s name and address or the quantity or cost of an item purchased. However, data can also be graphical images, sound files, movies and more.Characters ABC Decimals 8.0023 Sounds Images Integers 1234
  • 21. Errors • When a program has an error in it, that error is often called a “bug.” And the process of getting all of the errors out of a program is called debugging. • Funny story behind it :D
  • 23. Programming Languages • The computer internally operates on the binary number system. In the binary number system, the only valid digits are 0s and 1s. • Electronic circuits can either have some electricity in them or not. 1 means ON, and 0 means OFF. • No one writes programs in binary, it’s very tedious.
  • 25. C++ • C++ is the programming language we will learn in this course • The instruction that you used at the beginning of this session is actually C++ statement “cout << 6 + 7;”
  • 26. I/O • As we said, any program gets input from user and has an output, so how can we get input and return output ? • Let’s see ;)
  • 28. Output examples cout << “Hello World!!”; cout << 3; cout << “3”; cout << 5 * 15; cout << 15 / 5;
  • 29. Input • Let’s get input from user, But where we will save this data ?!!
  • 30. Variables • Do you remember when we talked about “Data” ? • So, where it will be saved ?! • We create variables to save data needed through the program or in files to be reused again and again (we will talk about files later) • Variables shouldn’t begin by a number, and shouldn’t have any spaces
  • 31. Data types • Since the variable holds data, so this variable should have a data type • Data types in C++ : – int integer number – float float numbers – double big numbers (int OR float) – char characters – Adding long more size for a variable EX: long int – bool return true or false – string
  • 32. Declaration and initialization • int x; – Here we say that we want to declare x as a variable from the type int (integer) • int x = 3; – Here , x is declared as an integer and also initialized by the value “3” • Note: it is a better practice to initialize your variables.
  • 33. Back to I/O • Now we can use these variables to take data from the user. • But how input actually works?
  • 35. I/O cont’ • So now, let’s take input and save it in avariable • We will use cin object , very similar to cout • For example : – Int x; – cin>>x • Here the value entered will be saved in variable x
  • 36. I/O example int x; cout<<“Enter a number: ”; cin>>x; cout << x + 5; Try it ;)
  • 37. I/O training • Get Two numbers from the user and print the result of multiplying them together. Input: 3 4 Expected out from your program: 12
  • 38. Answer int num1; int num2; cin >> num1; cin >> num2; cout << num1 * num2;
  • 39. Errors • There is two types of errors • Syntax : appears when you complie your code (error & warning) • Semantic (by logic) : appears when you run your program and you don’t get the desired output. • Example if you made a program to devide 2 numbers and you gave it 5/0, this wouldn’t give you the desired output.
  • 40. Operators  Now:  * / + - %  -- , ++ (before and after var)  =  Next sessions:  ==, < , <= , > , >=  || ,&& , >> , <<  | , &  ! , !=
  • 42. Special characters • a : make a sound when the program come to it • n : make a new line • r : make the cursor goes to the beginning of the line • t : make the cursor leave to the next tab • For example : – Cout<<“n” ; <- prints a new line – Cout<<“t”; <- prints a tab • We have also -> , ’ , ”
  • 43. Practice special char.s • cout << “line1nline2nline3”; • cout << “row1-col1trow1-col2n” << “row2-col1trow2-col2n”; • cout << “my name is “ahmed””; • cout << “path is c:folderfile.exe”; • cout << “maho enta aslan 3ayel teeta”
  • 44. I have a little confession I was hiding some code from you
  • 45. Simple Program # include <iostream> using namespace std; int main() { cout << “Hello World!!" ; return 0; }
  • 46. C++ Program • Wait wait wait a moment !! • Where will I write my program ? O_o
  • 47. IDE • IDEs are programs that help us to write new programs !! • IDEs as : Eclipse, Netbeans, Visual Studio, Dev C++ and others • So let’s open our IDE and write a program !
  • 48. Libraries # include <iostream> using namespace std; int main() { cout << “Hello World!!" ; return 0; }
  • 49. Libraries cont. • What are Libraries ?! • Every thing should extend from a library in C++ language • We declare the library on this form • #include< name of the library.h > – <> : we should surrounded the library name with this two brackets – .h : the extension of the library
  • 50. Namespace # include <iostream> using namespace std; int main() { cout << “Hello World!!" ; return 0; }
  • 51. Namespace cont. • We always add the line “Using namespace std;” at the beginning of the program, what does it means ?? • Why namespaces are useful ?
  • 52. Main # include <iostream> using namespace std; int main() { cout << “Hello World!!" ; return 0; }
  • 53. Main cont. • In C++ any program should have a main from which the program begin its work int main(){ // our program return 0; } • So soon we will know the meaning of each part of these stuff ! • But for now we will write our program inside the main
  • 54. Simple Program # include <iostream> using namespace std; int main() { cout << “Hello World!!" ; return 0; }
  • 55. Let’s get interactive with users # include <iostream> using namespace std; int main() { int num1, num2; cout << “Enter first number: " ; cin >> num1; cout << “Enter second number: ”; cin >> num2; cout << num1 << “+” << num2 << “=“ << num1+num2; return 0; }
  • 56. Notes for a good programmer • Indentation !!! • Variable names (naming ways) • Variables are case sensitive • Spaces and comments • Comments types (// , /* */) • initialize your variables
  • 57. Training 1 • Write a program that takes your name and say: – Hello “somebody”
  • 58. Training 2 • Write a program that takes from the user two numbers and calculate: – Sum – Difference – Multiplication – Division

Editor's Notes

  • #12: I want a machine that can take a recipe, a sequence of steps that will now act as described in the recipe, so it will change as it’s described in the sequence, it’s the basic part of each computer, this is now an example of stored program computer
  • #14: We will have a python demo here
  • #18: There is no Good Programming language and Bad one, but each suitable of specific kind of applications. So, Given a fixed set of primitives, all right, a good programmer can program anything. And by that, I mean anything that can be described in one of these process, you can capture in that set of primitives.
  • #22: The term originates in the first generation of computers when someone removed a fly that had gotten into the computercircuitry and shorted it out - they were “debugging” the computer. In fact, mostly workingsoftware is a pet peeve of mine.
  • #41: % &amp; /integer division