introduction to programming - mahmoud el-gayyar · introduction to programming introduction to c...

23
Introduction to Programming Lecture 1: Introduction to Programming Mahmoud El-Gayyar [email protected]

Upload: others

Post on 01-Jun-2020

27 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Introduction to Programming

Lecture 1: Introduction to Programming

Mahmoud El-Gayyar [email protected]

Page 2: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 2

Page 3: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 2

Be a Falcon

Page 4: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 2

Page 5: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 2

Introduction to the course

General information Syllabus Course organization General rules

Introduction to Programming

Programming Skills Programming Model Elements of a real Programming Languages History of C Compiler Terminology

Outline

Page 6: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 3

Introductionto the course

General information Syllabus Course organization General rules

Introduction to Programming

Programming Skills Programming Model Elements of a real Programming Languages History of C Compiler Terminology

Outline

Page 7: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 4

General Information

Lecture

Lecturer:

Contact:

Office hours:

Mahmoud El-Gayyar

[email protected]

Monday , 11:00 am to 12:00 pm (email)

Lab

Assistant: Contact:

Amira, Fatma ?

Textbooks

CS Department Many in the Library !!!

Course web page:

The notes and the assignmentswill be available online. http://elgayyar.weebly.com/

Page 8: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 5

Syllabus of the Lecture

Introduction to Programming

Introduction to C Language

Basic Data Types

Statements and Control Flow

Arrays

Functions and Program Structure

User-defined Data Types: Structures

Pointers and Memory Management

Page 9: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 6

Course Organization

2-3 lecture quizzes Midterm exam Assignments:

Submitted in Groups: 4-6 students One group will be selected to represent its solution Sometimes it helps to do it twice if you feels it is still difficult Deadline is a real deadline ?!! Half of the final mark

Bonus marks

Optional work, communication, clever or creative solutions

I monitor area of difficulty and adjust the material: lectures,

assignments, etc.

Page 10: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 8

Additional Hints

Don’t wait until the last minute each week

If you get stuck – move around – review material,

search Google, then come back

When you look back, you will see that this was all *really* easy

When you feel stuck – communicate– ask a friend or

come back to your assistant or to me.

Page 11: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 8

Rules !!

Page 12: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 9

Introduction to the course

General information Syllabus Course organization General rules

Introductionto Programming

Programming Skills Programming Model Elements of a real Programming Languages History of C Compiler Terminology

Outline

Page 13: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 10

What is Programming?

Page 14: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 11

Programming Skills

1. Attention to Details

4. Abstraction

3. Good Memory

2. Stupidity

Page 15: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 12

The Programming Model

A Computer Program:

Static Processing

Dynamic Valuable Information

Page 16: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 13

Problem Analysis and Specification

Algorithm Development

ProgramCoding

Executionand Testing

The Programming Model

Program lifecycle:

Input? Output? Process?

Pseudocode Flow chart

• Programming Language

• Bug-free

Page 17: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Where to store your data?

Memory Locations

Need to have certain types

Compute new values?

Store Values?

How to branch?

Variables (x, y, z)

Expressions (10+6)

Assignments(x= 10+6)

Conditionals

How to repeat?

How to simplify? Mahmoud El-Gayyar / Advanced Programming

Loops

Functions

Elements of a Real Programming Language

Control Flow 14

Page 18: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 15

Integers ( …, -2, -1, 0, 1, 2, …)

Float, Double (3.5, -4.002)

Characters: character set

‘A’

‘a’

‘$’

65

97

36

Strings: List of characters

“Hello” ‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘ɸ’

Numbers, Characters and Strings Numbers:

Page 19: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 16

Programming Languages

The Evolution of Computer Programming Languages

Low Middle High

Page 20: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 17

He also one of the Unix operatingsystem designers

A tool for programmers that needed:

More readable language than Assembly

Still have low level access capabilities

C is best for:

The programs that must run quickly

Need low level access to computer hardware (e.g. need direct

control of I/O or memory)

History of C

Dennis Ritchie (American) created C in 1972

Page 21: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 18

Compiler Terminology

Convert your source code into machine-languageexecutable programs.

Compiler (e.g. C ) or Interpreter (Basic)

Interpreter

Line by line and result available immediately No executable

To run, need the interpreter (in general slower than the compiler)

Page 22: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 19

Compiler Terminology

Source File

(.c, .cpp)

Source File

(.c, .cpp)

Compiler Object File

(.obj)

Object File

(.obj)

Linker

Executable

File (.exe)

Compiler

Page 23: Introduction to Programming - Mahmoud El-Gayyar · Introduction to Programming Introduction to C Language Basic Data Types Statements and Control Flow Arrays Functions and Program

Mahmoud El-Gayyar / Advanced Programming 20

Always check the course webpage Again, don‘t forget the deadline rule

Introduction to programming

What is C Language?

Compiler vs. Interpreter

Summary

Introduction to the course