Unit 1: Introduction to Programming · PDF file“Programming In Ansi C” By E....
-
Upload
trinhhuong -
Category
Documents
-
view
876 -
download
30
Transcript of Unit 1: Introduction to Programming · PDF file“Programming In Ansi C” By E....
Saurabh Khatri Lecturer
Department of Computer TechnologyVIT, Pune
Unit 1: Introduction to Programming
Syllabus Unit 1: Introduction to Programming
Unit 2: Flow of Control and Functions
Unit 3: Arrays and Strings
Unit 4: Pointers and Structures
Unit 5: Recursive Functions – Sorting and Searching
Books to refer “Let us C”, Y. Kanetkar, Second Edition, BPB Publication. ISBN:
8176566217. “Programming In Ansi C” By E. Balagurusamy Tata McGraw-Hill
Education, 2008 “Programming language – ANSI C”, Brain W Kernighan and Dennis
Ritchie, Second edition ISBN 0-13-110370-9, Fundamentals of Computer System - Pradeep Sinha. For Unit 1
Assessment Total assessment = 100 15 – CT (7.5) on Unit 1+ HA (6*5 = 30 ------ 7.5) – Part B 20 – Mid Sem (Online test) MCQ – Unit 2,3 65 – End Sem (100 marks to be converted to 65)[Distribution of Marks Unit wise : 14+14+14+22+22+14]
4 Functions of a Computer Input : Any raw data given to Computer system Processing : Operations on Input according to set of
instructions. Output : Interpreting processed information to User Storage : Storing the results for future use.
Operating Systems System Software that controls the entire Computer System. Provides user with an interface to work with the Machine More convenient
Two way work of OS : Convenience + Resource management
Main functions Process mgmt Memory mgmt File mgmt Security
DOS OS that provides management of secondary storage devices Extension to the OS DOS was first used for IBM PCs using 32-bit Intel Processors
(x86). Microsoft developed the - Microsoft Disk Operating System
(MSDOS), MS windows 2007, XP are coming from it. Replaced by Windows OS completely Examples include DOS/360 and FreeDOS.
UNIX OS Unix is a multitasking, multi-user computer operating
system Developed in 1969 by a group of AT&T Bell Labs Contributors includes Ken Thompson, Dennis Ritchie, Brian
Kernighan and team Unix written in C language.
Levels of Programming Language Machine Language
Consists of combination of 0’s and 1’s that represent high and low electrical voltage. Unsuitable for programming, difficult to program. Machine dependent. Error prone. All programs are converted into machine language before they
can be executed.
Levels of Programming Language Assembly Language Similar to Machine level but replacing 0s and 1s with Names
and symbols Also known as Object code Uses symbolic codes to represent the machine operation code More readable Can be used to write instructions. Ex: ADD ------- 3E, etc Platform Dependent .obj extension
Levels of Programming Language High-Level Languages Programming languages that are easier to learn. Uses English like statements. Readable familiar notations Availability of program libraries Platform Independent. Hides the details of computer. Example C language (.c extension)
Execution of a Program
High Level source code(.c)
Middle level object
code(.obj)
Low level executable code(.exe)
ALGORITHMS AND FLOWCHARTS
A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of
problem this sequence of steps is called an algorithm
Implementation phase implement the program in some programming language
Example 1 Example 1:Write an algorithm to determine a student’s final
grade and indicate whether it is passing or failing. Algorithm
Step 1: StartStep 2: Input M1,M2,M3,M4Step 3: GRADE (M1+M2+M3+M4)/4 Step 4: if (GRADE < 50) then
Print “FAIL”else
Print “PASS”endif
Step 5: Stop
Flowchart A graphical representation of the sequence of operations
in an information system or program. Different symbols are used to draw each type of
flowchart. A Flowchart shows logic of an algorithm emphasizes individual steps and their interconnections e.g. control flow from one action to the next
Example
PRINT“PASS”
Step 1: Input M1,M2,M3,M4Step 2: GRADE (M1+M2+M3+M4)/4 Step 3: if (GRADE <50) then
Print “FAIL”else
Print “PASS”endif
START
InputM1,M2,M3,M4
GRADE(M1+M2+M3+M4)/4
ISGRADE<50
PRINT“FAIL”
STOP
YN
Example 2 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area.
Example 2
Algorithm Step 1: Input W,L Step 2: A L x W Step 3: Print A
START
InputW, L
A L x W
PrintA
STOP
Revision – 15 Marks1. 4 functions of Computer? 2. Why RAM is also called Non Volatile. 3. Which is faster secondary or primary memory?4. Function of control unit?5. What is OS – example6. C is a _______________ level language.7. Machine code contains ______________ and has an extension ____________. 8. What is the function of Linker. 9. C is a Interpreted Language ? T or F. 10. Loader is part of ____________ and is used to __________________________. 11. For processing the executable file are brought to __________________ from
______________________. 12. Write an example of O/P and I/P device. 13. Interpretation process does not create any ___________________. That’s why it has a
drawback________________________. 14. Assembler function is to ________________________________________.15. is ____________________box