BUE Lecture 1 Intro
BUE Lecture 1 Intro
PROGRAMMING AND
SOFTWARE DESIGN/
23ECE12C
LECTURE 1 COMPUTER
PROGRAMMING
1
Module Logistics
Module Leader
– Dr. Sally Saad
Lecturer in Faculty of Computer and Information Sciences -Ain Shams University
• Contact: [email protected]
• Office hours availability:
– On Wednesday 11:00 am – 12:30 pm at externals room Building A last floor
» (Set an appointment before it at least with 24 hrs)
– Via email [email protected]
– Via messenger: https://www.facebook.com/Sally.S.Ismail
• Online Office hours:
– Sunday @ 2pm via link
https://us04web.zoom.us/j/8293143395?pwd=SE11djNMWjBKQmZYR0dUWmV
5VGt2UT09
Meeting ID: 829 314 3395
Passcode: 052872 2
Module Logistics
• Teaching Assistant
– TA\ Ameera Amer
• [email protected]
• Ask her for her office hours.
• Office: E106
3
Module Logistics
– Introduce yourself.
– Please let the SR contact me.
4
Module Logistics
• Class meets:
– 2-hours lecture
– 2-hours lab
– Tutorial
• Assessment (100 points)
Final Examination 60
In Campus Assignment 1 (W5) 10
In-Class Examination (W8) 20
In Campus Assignment 2(W10) 10
----------------------------------------------------
TOTAL 100
5
Module Logistics – Textbook
Available References:
• Starting Out with C++: Early Objects, 9e Edition
,Tony Gaddis, Judy Walters, Godfrey Muganda ISBN:
9781292157313,Pearson, 2016.
• C++ How to Program, 5th edition, Deitel & Deitel,
Prentice Hall- Pearson Education International, 2005.
Other References
• Problem Solving with C++, 8th edition, Walter Savitch,
Addison Wesley-Pearson Education International, 2012.
• Any online reference/tutorial/video explaining
the topic is accepted.
6
EXPECTED CODE OF CONDUCT
7
Note : A problems’ sheet will be available weekly via E-Learning for practicing.
Intended Learning Outcomes (ILOs)
8
WHY DO ELECTRIC ENGINEERS NEED TO
LEARN PROGRAMMING?
9
WHY DO
COMPUTER
ENGINEERS
NEED TO LEARN
PROGRAMMING?
10
Programming Applications
PROGRAMMING APPLICATIONS
11
Reference
FUN FACTS
☺
12
Module Logistics – Outline
1. Introduction to Programming: Review on previous concepts.
2. Control Structures: Sequential, Conditional, Iterative.
3. 1D Array + Searching.
4. Sorting 1D Array + 2D array
5. Functions 1 (by value) + built-in Functions.
6. Functions 2 (By Ref) + Passing arrays.
7. Problem Solving I
8. Pointers I.
9. Pointers II and dynamic 1D Array.
10. OOP Concepts 1: Abstract Data Type, Classes and Objects,
Encapsulation, and Access modifiers.
13
14
Revision
15
Problem Solving
17
Problem Solving
Steps of Solving a Problem:
1. Define the problem
2. Design a solution
– How to reach output from input
– Plan a solution
Analysis
– List steps of solution
Algorithm
18
Problem Solving – (cont.)
• An algorithm is simply the sequence of steps
taken to solve a problem.
• The steps are normally “sequence”,
“selection”, or “iteration”, statements.
• An algorithm is written as a pseudo code
which is a kind of structured English for
describing algorithms. It allows the designer to
focus on the logic of the algorithm without
being distracted by details of language syntax
(language independent).
19
Problem Solving – (cont.)
22
2 Programming Techniques & Languages
23
Developing a Program Steps:
• C++ Development Environment
1- Creating Program
- Source code
- Popular IDEs: Microsoft® Visual Studio, Dev
C++, NetBeans, Code Blocks, Eclipse.
2- Preprocessing
- Automatically
- Preprocessor directives (#include, #define)
24
Developing a Program Steps:
• C++ Development Environment
3- Compiling
- Create Object code
(detecting syntax errors)
4- Linking
- executable code
25
Developing a Program Steps:
• C++ Development Environment
5- Loading
- With other needed libraries.
6- Executing
- One instruction at a time.
26
Developing a Program Steps:
• C++ Created Files/Folders
Project Folder include:
Debug folder
•Includes .exe file
(Application itself)
•Includes other files
related to the debug
or the release of the
project
.sdf
*.sln file database file
Opens the whole
Beyond our scope ☺
solution on the IDE
Solution Folder
•Includes different Project(s) within your solution
•Includes Source file(s).cpp file(s)
•Includes other projects files like .h file(s)
27
•Includes other files like log files
Programming Techniques
1. Unstructured Programming
2. Procedural (Structured)Programming
3. Modular (Object Oriented) Programming
4. Logic Programming
28
Main Program
Data
29
3. OBJECT-ORIENTED PROGRAMMING
Data
Module1 Module2
30
31
C++
PROGRAM
C++ Programming
Libraries and
namespaces
void
functions
Variables
Input/output
Control
Structure
32
Namespaces
• Namespaces defined:
– Collection of name definitions
• For now: interested in namespace "std"
– Has all standard library definitions we need
• Examples:
#include <iostream>
using namespace std;
• Includes entire standard library of name definitions
#include <iostream>
using std::cin;
using std::cout;
• Can specify just the objects we want 33
IDENTIFIERS
AND
LITERALS
IDENTIFIERS TYPES (FYI)
35
Variables – Exercise
(Pre and Post Increment/Decrement)
Example: Evaluate the following
36
Variables
ASSIGNING DATA: SHORTHAND
NOTATIONS
37
Variables
Compatibility of Data Assignments
Type mismatches
General Rule: Cannot place value of one type
into variable of another type
int Var = 2.99; // 2 is assigned to Var!
Two types
Implicit—also called "Automatic"
Done FOR you, automatically
17 / 5.5;
This expression causes an "implicit type cast" to
take place, casting the 17 → 17.0
39
LITERALS
Literals
Examples:
2 // Literal constant int
5.75 // Literal constant
double
‘Z’ // Literal constant char
"Hello World" // Literal constant string
40
Defining Constants:
const Vs. #define
41
Defining Constants:
const Vs. #define
42
Defining Constants:
const Vs. #define
const #define
Should specify data type No data type
Takes space in memory No memory used
Should have initialization statement ending No semicolon
with a semicolon
Can Not be modified
Can not be modified later
Replaces the const name with the value
Preferred name in capital letters. beside it.
Placed anywhere in the program preferably Uses preprocessor directive and is placed
after the function header (main()) after #include
E.g E.g.
const int SIZE=10; #define SIZE 10
43
Operators
Operators Precedence
44
Arithmetic Operators
• Standard Arithmetic Operators
– Precedence rules – standard rules
– Parentheses?
Evaluate: z= 2 * 10 % 3 + 6 / 2 – 1; 45
TYPES OF ERRORS
46
I. SYNTAX ERRORS
Example: Syntax Error:
identifier name can
They are errors in code void main() not start with a
structure (Syntax) or { number
grammar (Semantics). int 0product = 1;
for (int i = 1; i <= 15; i++)
Easily detected in product *= i;
Compilation process. cout << "Product: " << product
<< endl
Easily fixed. }
Program does NOT run Syntax Error:
till all syntax/semantic missing semi-colon
errors are fixed.
47
2. LOGIC ERRORS
Example: Syntax Error: Logical
They are errors in the logic error, += instead of
of the code. void main() *=
{
Might be the designer int product = 1;
mistake or a typing for (int i = 1; i >= 15; i++)
mismatch by the developer. product += i;
Can NOT be detected in cout << "Product: " << product
Compilation process. << endl;
49
EXERCISES SHEET
WILL BE
RELEASED
WEEKLY VIA E-
LEARNING FOR
THOSE WHO
WANT BETTER
CAREER ;-)
50
HOW TO STUDY THIS MODULE?
52