Introduction to Programming. Lecture 2: Introduction to C

Similar documents
Introduction to Programming. Lecture 6: Functions & Program Structure

Visual Programming. Lecture 3: Loops, Arrays. Mahmoud El-Gayyar

Introduction to C Programming. What is a C program?

Introduction to Programming. Structures

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C

AMCAT Automata Coding Sample Questions And Answers

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Agile Software Development. Lecture 7: Software Testing

Fundamentals of Multimedia. Lecture 5 Lossless Data Compression Variable Length Coding

INTRODUCTION TO PROGRAMMING. Prepared by: Mahmoud El-Gayyar. Computer Science Department. Faculty of Computers and Informatics. Suez Canal University

Welcome! COMP s1. Programming Fundamentals

Welcome! COMP s1. Programming Fundamentals

Introduction to C Programming

FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm)

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

Introduction to C. CS 2060 Week 1. Prof. Jonathan Ventura. Outline Introduction Introduction to C Homework 1 C Coding Style Wrap-up

Programming in C. What is C?... What is C?

Programming in C UVic SEng 265

Programming in C. What is C?... What is C?

CS 31: Intro to Systems Binary Arithmetic. Martin Gagné Swarthmore College January 24, 2016

COMP s1 Lecture 1

CpSc 111 Lab 3 Integer Variables, Mathematical Operations, & Redirection

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

Introduction to Computing Lecture 09: Functions (Part II)

Formatted Input/Output

Visual Programming. Lecture 2: More types, Methods, Conditionals

Decision Making and Loops

Programming in C - Part 2

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

Summary of Lecture 4. Computer Programming: Skills & Concepts (INF-1-CP1) Variables; scanf; Conditional Execution. Tutorials.

Introduction to Computing Lecture 08: Functions (Part I)

Welcome! COMP s1. Programming Fundamentals

Welcome! COMP s1 Lecture 7. COMP s1. Before we begin. Strings. Programming Fundamentals. Overview. Andrew Bennett

Carleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

Control Structure: Selection

COMP 2355 Introduction to Systems Programming

CS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018

University of Maryland College Park Dept of Computer Science CMSC106 Fall 2016 Midterm I

CMSC 104 -Lecture 9 John Y. Park, adapted by C Grasso

Fundamentals of Programming Session 12

Introduction to C Programming

CpSc 1111 Lab 5 Formatting and Flow Control

Programming Language B

CMPT 115. C tutorial for students who took 111 in Java. University of Saskatchewan. Mark G. Eramian, Ian McQuillan CMPT 115 1/32

CSCE150A. Introduction. While Loop. Compound Assignment. For Loop. Loop Design. Nested Loops. Do-While Loop. Programming Tips CSCE150A.

Informatica e Sistemi in Tempo Reale

Fundamentals of Programming

Physics 2660: Fundamentals of Scientific Computing. Lecture 5 Instructor: Prof. Chris Neu

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 5. Repetition in Programs. Notes. Notes. Notes. Lecture 05 - Loops

COMP1917: Computing 1 1. Introduction

Mobile Development Lecture 11: Activity State and Preferences

1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters

COMP1917: Computing 1 1. Introduction

C Concepts - I/O. Lecture 19 COP 3014 Fall November 29, 2017

Introduction to OS. Deadlock. MOS Ch. 6. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

CSE101-Lec#18. Multidimensional Arrays Application of arrays. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU. LPU CSE101 C Programming

C and C++ I. Spring 2014 Carola Wenk

Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II

CpSc 1111 Lab 4 Formatting and Flow Control

1. Introduction. Course Web Site. COMP1917: Computing 1. Textbook. Occupational Health and Safety (OHS)

Couple Notes about Boolean Expressions in C

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Outline. Computer programming. Debugging. What is it. Debugging. Hints. Debugging

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

C Programming Language

Debugging (Part 1) The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 5

Chapter 4: Expressions. Chapter 4. Expressions. Copyright 2008 W. W. Norton & Company. All rights reserved.

ENGR101: Lecture 7. C language tools and intro to C programming. March ENGR101: Lecture 7 March / 20

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Introduction to 8086 Assembly

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

Fundamental of Programming (C)

CGS 3460 Summer 07 Midterm Exam

Simple if Simple if-else Nested if - else Notes for if-else statement Logical operators

Variables and literals

Software Lesson 1 Outline

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Functions. Cedric Saule

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

Welcome! COMP s1. Programming Fundamentals

Programming. Data Structure

CSC209H Lecture 5. Dan Zingaro. February 4, 2015

C Introduction Lesson Outline

Array Initialization

The Compilation Process

CS Spring 2018 Homework #5

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

CS 241 Data Organization. August 21, 2018

Week 3 More Formatted Input/Output; Arithmetic and Assignment Operators

!"#$% &'($) *+!$ 0!'" 0+'&"$.&0-2$ 10.+3&2),&/3+, %&&/3+, C,-"!.&/+"*0.&('1 :2 %*10% *%7)/ 30'&. 0% /4%./

Principles of C and Memory Management

Fundamentals of Programming

G52CPP C++ Programming Lecture 3. Dr Jason Atkin

make and makefile CS 211

Question 1. Part (a) [2 marks] error: assignment of read-only variable x ( x = 20 tries to modify a constant) Part (b) [1 mark]

Transcription:

Introduction to Programming Lecture 2: Introduction to C Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg

Review Lecture 1 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 Mahmoud El-Gayyar / Advanced Programming 2

Review Lecture 1 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 Mahmoud El-Gayyar / Advanced Programming 3

Outline Introduction to C Langauge Your First C Program Let s have another example Program Structure Mahmoud El-Gayyar / Advanced Programming 4

Introduction to C Langauge Your First C Program Let s have another example Program Structure Outline Mahmoud El-Gayyar / Advanced Programming 5

Programming Language A programming language is a tool Can not perform every task unaided C language has built-in functions But not for every thing C is a dangerous language Provide low level access to memory You should be careful while dealing with it Mahmoud El-Gayyar / Advanced Programming 6

Introduction to C Langauge Your First C Program Let s have another example Program Structure Outline Mahmoud El-Gayyar / Advanced Programming 7

Introduction to C Langauge Your First C Program Let s have another example Program Structure Outline Mahmoud El-Gayyar / Advanced Programming 8

Your First C Program #include <stdio.h> int main() { } printf("hello, world!\n"); return 0; 9

Your First C Program #include <stdio.h> int main() { } printf("hello, world!\n"); return 0; 10

Your First C Program #include <stdio.h> int main() { } printf("hello, world!\n"); return 0; 11

Your First C Program #include <stdio.h> int main() { } printf("hello, world!\n"); return 0; 12

Your First C Program #include <stdio.h> int main() { } printf("hello, world!\n"); return 0; 13

Introduction to C Langauge Your First C Program Let s have another example Program Structure Outline Mahmoud El-Gayyar / Advanced Programming 14

Your Second C Program #include <stdio.h> /* print a few numbers, to illustrate a simple loop */ int main() { int i; // single line comment } for(i = 0; i < 10; i = i + 1) printf("i is %d\n", i); return 0; Mahmoud El-Gayyar / Advanced Programming 15

Your Second C Program #include <stdio.h> /* print a few numbers, to illustrate a simple loop */ int main() { int i; // single line comment } for(i = 0; i < 10; i = i + 1) printf("i is %d\n", i); return 0; Mahmoud El-Gayyar / Advanced Programming 16

Your Second C Program #include <stdio.h> /* print a few numbers, to illustrate a simple loop */ int main() { int i; // single line comment for(i = 0; i < 10; i = i + 1) printf("i is %d\n", i); return 0; } Mahmoud El-Gayyar / Advanced Programming 17

Your Second C Program #include <stdio.h> /* print a few numbers, to illustrate a simple loop */ int main() { int i; // single line comment for(i = 0; i < 10; i = i + 1) printf("i is %d\n", i); return 0; } Mahmoud El-Gayyar / Advanced Programming 18

Introduction to C Langauge Your First C Program Let s have another example Program Structure Outline Mahmoud El-Gayyar / Advanced Programming 19

Program Structure Mahmoud El-Gayyar / Advanced Programming 20

C is Case-Sensitive So if you write Main instead of main or int instead of int, the compiler will give you an error Mahmoud El-Gayyar / Advanced Programming 21

1st Good Programming Style (Indentation) C don t care about spaces for(i = 0; i < 10; i = i + 1) printf("%d\n", i); for(i = 0; i < 10; i = i + 1) printf("%d\n", i); for(i = 0; i < 10; i = i + 1) printf("%d\n", i); for = i ; i ) "%d\n" ) ( 0 < i + printf, ; i ; 10 = 1 ( i Mahmoud El-Gayyar / Advanced Programming 22

C program Summary May contain several functions It can also use built-in functions (don t forget the include) Must have a main function It may return a value (0, -1) Comments can be used to enrich your program and make it more readable C is case sensitive Indentations (white spaces) is a good programming style Mahmoud El-Gayyar / Advanced Programming 23