B.Sc., COMPUTER SCIENCE PROGRAMING C 1 YEAR MAJOR PAPER - 1 FIRST YEAR NON SEMESTER 2020-2021
Total Page:16
File Type:pdf, Size:1020Kb
B.Sc., COMPUTER SCIENCE PROGRAMING C 1 YEAR MAJOR PAPER - 1 FIRST YEAR NON SEMESTER 2020-2021 July-2020 (New Print) 150 Programming in C MAJOR PAPER I PROGRAMMING IN C UNIT – I Evolution and Applications of C - Structure of a C program – Data types – Declarations – operators – Expressions – Type conversions – Built-in functions. UNIT – II Data Input and Output – Control statements: IF, ELSE-IF, GOTO, SWITCH, WHILE-DO, DO-WHILE, FOR, BREAK and CONTINUE. UNIT – III Functions: Defining and Accessing Arguments – recursive functions – storage classes – Arrays: Defining and processing Arrays – Multidimensional arrays – passing arrays to functions – Arrays and strings – String functions – String Manipulation. UNIT – IV Pointers – Pointer Declarations – Operations on pointers – pointers to functions – Pointer and strings – pointers and arrays – array of pointers – structures – structures and pointers – unions. UNIT – V Data files – Opening, closing and processing files – files with structures and unions – register variables – Bitwise Operations – Macros – Preprocessing. Text Book: “Programming in C” – E.Balagurusamy – Tata McGraw Hill Publications. Books for Reference: 1. “Programming with C” – Byron S.Gottfried – Schaum’s outline series – Tata McGraw Hill Publications. 2. “The Sprit of C” – Mullish cooper – Schaum’s Outline Series – Tata McGraw Hill Publications. 3. “A first course in Programming with C” – T.Jeyapoovan, Vikas Publishing Hous Pvt. Ltd., New Delhi. Programming in C Table of Contents C PROGRAMMING LANGUAGE ..................................................................................................................................... 1 UNIT I .............................................................................................................................................................................. 1 1.1 EVOLUTION OF C .................................................................................................................................................... 1 1.1.1 Origin of C ............................................................................................................................................................ 1 1.1.2 HISTORY OF C ....................................................................................................................................................... 3 1.1.3 IMPORTANCE OF C ............................................................................................................................................... 4 1.2 APPLICATIONS OF C LANGUAGE ....................................................................................................................... 5 1.2.1 USES ..................................................................................................................................................................... 5 1.2.2ADVANTAGES ........................................................................................................................................................ 5 1.2.3 Facts about C ........................................................................................................................................................ 6 1.2.4 Why to use C? ...................................................................................................................................................... 6 1.3 STRUCTURE OF THE C PROGRAM ...................................................................................................................... 7 1.3.1Programming Style ................................................................................................................................................ 8 1.3.2 Good Program Style: ............................................................................................................................................ 9 1.3.3Data types in C Language ...................................................................................................................................... 9 1.3.4 Modifiers ............................................................................................................................................................ 11 1.3.5Qualifiers ............................................................................................................................................................. 12 1.4 What are Arrays: ....................................................................................................................................................... 13 1.4.1 Array Initialization .............................................................................................................................................. 14 1.5 Keywords: ................................................................................................................................................................. 16 1.6 What is Operator? ..................................................................................................................................................... 17 1.6.1 Arithmetic Operators: ........................................................................................................................................ 17 1.6.2 Logical (or Relational) Operators: ...................................................................................................................... 18 1.6.3 Bitwise Operators: ............................................................................................................................................. 19 1.6.4 Assignment Operators: ...................................................................................................................................... 20 1.6.5 Misc Operators ................................................................................................................................................... 21 1.7 Constants: .................................................................................................................................................................. 23 1.7.1 Defining Constants ............................................................................................................................................. 23 1.8 The enum Data type ................................................................................................................................................. 24 1.9 Expressions : ............................................................................................................................................................. 25 1.9.1 Evaluation of Expressions .................................................................................................................................. 26 1.9.2 Rules for evaluation of expression ..................................................................................................................... 27 1.10 Type conversions in expressions ............................................................................................................................. 27 1.10.1 Implicit type conversion ................................................................................................................................... 27 Programming in C 1.10.2 Explicit Conversion ........................................................................................................................................... 28 1.11 BUILT IN FUNCTIONS ........................................................................................................................................ 30 UNIT II .......................................................................................................................................................................... 33 2.1 MANAGING INPUT AND OUTPUT OPERATIONS ........................................................................................... 33 2.1.1 UNFORMATTED I/O FUNCTIONS ........................................................................................................................ 34 TO READ AND WRITE SINGLE CHARACTER ...................................................................................................... 34 getchar() ....................................................................................................................................................................... 34 2.1.2 FORMATTED I/O FUNCTIONS FORMATTED INPUT .......................................................................................... 35 2.2 DECISION MAKING AND BRANCHING STATEMENT ................................................................................... 36 2.2.1 IF STATEMENT .................................................................................................................................................... 36 2.2.2 If …… else............................................................................................................................................................ 37 2.2.3 Nested if ............................................................................................................................................................. 38 2.2.4 else … if ladder ................................................................................................................................................... 39 2.3 SWITCH STATEMENT........................................................................................................................................... 41 2.4 GOTO