Unit 1: Introduction to Programming Saurabh Khatri Lecturer Department of Computer Technology VIT, Pune
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]
What is a Computer?
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.
Block Diagram of Computer
Operating System
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)
Program Execution
Program Execution Compiler Assembler Linker Loader Interpreter (Video - )
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: Start Step 2: Input M1,M2,M3,M4 Step 3: Step 4: Step 5: GRADE (M1+M2+M3+M4)/4 if (GRADE < 50) then Print FAIL else Print PASS endif 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
Flowchart Symbols Basic
Example START Input M1,M2,M3,M4 GRADE (M1+M2+M3+M4)/4 Step 1: Step 2: Step 3: Input M1,M2,M3,M4 GRADE (M1+M2+M3+M4)/4 if (GRADE <50) then Print FAIL else Print PASS endif N IS GRADE<50 Y PRINT PASS PRINT FAIL STOP
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: Step 2: Step 3: Input W,L A L x W Print A START Input W, L A L x W Print A STOP
Example 3 Write an algorithm and flowchart to print the factorial of a no. N.
Revision 15 Marks 1. 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 example 6. 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