Lecture On C

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Lecture On C as PDF for free.

More details

  • Words: 1,314
  • Pages: 34
C Programming Lecture 01

Contact Info Email: [email protected]  Course Web site: http://csd/courses/CSDC110/ 



CCH: --- Friday (3 pm to 4 pm)

10/15/08

2

Course Information 

 

Two Lectures / Week 

Monday – 5:30 -7:00 P.M



Wednesday –5:30 – 7:00 P.M

Total Lectures: 22 (Planned) Room No: 5103

10/15/08

3

Course Information 

Introduction to Computer Programming using the C programming language.



No prior programming experience is required.



Goal of the course: make you capable of writing good programs in C.

10/15/08

knowledge

or

4

Lectures 

Sets pace of Course



Highlights important points



Program samples presented (Ensure that you understand them fully)



Available on the course website

10/15/08

5

Exercises 

Can only learn by doing them.



Study examples from Class.



Try several programs.



Take home practice exercises.

10/15/08

6

Evaluation 

Assignments-02

Take home



Midsem Test

90 minutes



Final Exam

180minutes



Any absence for the evaluation components must be pre-approved by the instructor.



Attendance-- 75%

10/15/08

7

Programming Assignments 

Each Programming assignment will be given one week before.



Programs must be submitted electronically by 11:59 p.m. on the due date to get full credit.

10/15/08

8

Academic Honesty 

Cheating of any kind will not be tolerated. 







The program assignments are to be individual effort. You may discuss program ideas with others, but you should not copy C code from others. If you submit a program that is not your own, the penalty ranges from a zero for the assignment to instant failure of the class. You are always free to ask for help from the instructor.

10/15/08

9

Course Contents 

Overview and Introduction to Programming and C language



Basic C Programming Concepts



Data

Types,

Operands,

Precedence

and

Expressions 

Basic I/O



Control Statements



Expression and Conversions

10/15/08

10

Course Contents 

Functions



Arrays



Addresses, Pointers and Indirection



Storage Classes and Process Library Functions



Structures and Unions



File Processing



Data Structures

10/15/08

11

Reading 

Textbook Schaum's Outlines of Programming with C by Byron S. Gottfried Reference Books 

  

The C Programming Language, B. W. Kernighan and D. M. Ritchie. Let Us C, Y. Kanetkar. A Book on C, Al Kelley, Ira Pohl . C Programming Language , E. Balaguruswamy.

10/15/08

12

Objectives 

Introductory understanding of 

Computers



Algorithm / Pseudo code / Flowchart



Top-down Model



Programming Languages



Introduction to C Language

10/15/08

13

What is Computer? 

Computer 





Hardware  



Device capable of performing computations and making logical decisions Computers process data under the control of sets of instructions called computer programs Various devices comprising a computer Keyboard, screen, mouse, disks, memory, CD-ROM, and processing units

Software 

10/15/08

Programs that run on a computer

14

Computer Organization 

Six logical units 

Input unit 



Output unit 



Supervises and coordinates the other sections of the computer

Secondary storage unit 

10/15/08

Performs arithmetic calculations and logic decisions

Central processing unit (CPU) 



Rapid access, low capacity, stores input information

Arithmetic and logic unit (ALU) 



Outputs information (to screen, to printer)

Memory unit 



Obtains information from input devices (keyboard, mouse)

Cheap, long-term, high-capacity storage 15

Algorithm 

Procedure or formula for solving a problem



Precise, unambiguous description sequence of computations



Each step is a precise, unambiguously defined transformation of data



Computer programs are algorithms written in a language designed such that the algorithm can be executed on a computer

10/15/08

of

a

16

Pseudo code 

Artificial, informal language that helps us develop algorithms



Similar to everyday English



Not actually executed on computers



Helps us “think out” a program before writing it 

Easy to convert into a corresponding program



Consists only of executable statements

10/15/08

17

Flowchart 

Graphical representation of an algorithm



Drawn using certain special-purpose symbols connected by arrows called flow lines.



Rectangle symbol (action symbol): indicates any type of action.



Oval symbol: indicates beginning or end of a program, or a section of code (circles).

10/15/08

18

Algorithm Pass/NoPassGrade Input: One number • if (the number is greater than or equal to 70) then 1.1 Set the grade to “pass” else 1.2 Set the grade to “nopass” End if 4. Return the grade End

10/15/08

19

Flowchart & Pseudocode Start Sum=0 Count = 0

Flowchart

Input Grade

Sum = Sum + Grade Count = Count + 1

Yes

More grades? No

Average = Sum/Count

Stop

10/15/08

Pseudocode BEGIN Average Grade sum=0 count = 0 DO INPUT grade IF grade < 0 EXIT sum = sum + grade count = count +1 END DO IF count > 0 THEN average = sum/count ELSE average = 0 END IF END Average Grade 20

Top-Down Approach 

Structured programming is often (but not always) associated with a "top-down" approach to design.



Designers map out the large scale structure of a program in terms of smaller operations, implement and test the smaller operations, and then tie them together into a whole program.

10/15/08

21

Top-Down Model 

In the Top-Down Model an overview of the system is formulated, without going into detail for any part of it. Each part of the system is then refined by designing it in more detail. Each new part may then be refined again, defining it in yet more detail until the entire specification is detailed enough to begin development.



Top down approaches emphasize planning, and a complete understanding of the system.

10/15/08

22

http://leo.stcloudstate.edu/acadwrite/intro.html

10/15/08

23

Programming Languages 

Machine languages

Strings of numbers giving machine specific instructions Example: +1300042774 +1400593419 +1200274027 10/15/08

24

Programming Languages 

Assembly languages English-like abbreviations representing elementary computer operations (translated via assemblers) Example: LOAD PRICE ADD TAX STORE COST

10/15/08

25

Programming Languages 

High-level languages Similar to everyday English and use mathematical notations (translated via compilers) Example: Cost = Price + Tax

10/15/08

26

Syntax and Semantics 

The syntax of a programming language: 







Set of rules that specify allowable statements in the language. Specification for the function of each word in statements in the language. Similar to a grammar for a natural language.

The semantics of a programming language: 

10/15/08

Rules for interpreting the computational operations specified by statements in a programming language.

27

Program Development

10/15/08

28

Introduction to C 

General purpose programming language.



Closely related to UNIX



Often referred as a system programming language as useful for writing compilers and operating systems.

10/15/08

29

History of C 

1960 – block-structured ALGOL emerged



1967 – Martin Richards developed BCPL (Basic Combined Programming Language)



1970 – Ken Thompson developed B while working on DEC PDP7, B originated from BCPL



BCPL and B are both typeless languages



1972 – Dennis Ritchie and Ken Thompson developed C (with data types) – traditional C



1989-1990 – ANSI and ISO standard for C approved.

10/15/08

30

Features of C 



Portability 

Implemented on many diverse systems



Implemented on wide variety of hardware



Defined libraries are themselves portable



Applications are portable



Programmes are portable

Powerful 

Completeness – business to scientific applications



Flexibility – preprocessor, conditional compilation, header files

10/15/08

31

Features of C 

Structured Programming – readability and maintainability



Both a high level and low level language 

High level – symbolic references, user written functions, powerful operator set, derived data types



Low level – allow reference to storage directly, bits and bit patterns manipulation

10/15/08

32

Summary 

We have got idea about 

Computers



Algorithm and Programming



Top-down approach



C Language

10/15/08

33

10/15/08

34

Related Documents

Lecture On C
November 2019 8
C++lecture
May 2020 13
Lecture 2 C Programming
November 2019 6
Lecture On Gandhi
December 2019 8