Transcription of Programming with C - Lab
1 ANIL NEERUKONDA INSTITUTE OF TECHNOLOGY AND SCIENCES (AUTONOMOUS) Programming with C - Lab Semester - I (Common to All Branches) Prepared by Departments of IT & CSE Unit 1 - page no - 2 Unit 2 - page no - 49 Unit 3 - page no - 101 Unit 4 - page no - 128 to 141 Pointerspage no - 152 to 176 FunctionsUnit 5 - page no - 142 to 151 Structurespage no - 177 FilesProgramming with C - Lab Prepared by IT & CSE Page 2 TABLE OF CONTENTS WEEK CONTENT PAGE NO 1 Fundamentals of computer Hardware, Introduction to Programming Languages & Translators, DOS/UNIX Commands 3-23 2 Algorithms & Flowcharts, Introduction to C, History, Steps of Learning C, C Tokens.
2 Data Types - Format Specifiers, I/O Statements, Structure of C Program, Sample C Programs 24-48 3 Operators in C, their Precedence and Associativity, Arithmetic Expressions/Instructions, Type casting, functions, Sample C Programs 49-64 4 Control Statements (Conditional): If and its Variants, Switch (Break), Sample C Programs 65-81 5 Goto Statement, Control Statements (Looping): While, , For Loop, Continue & Break (Unconditional), Nested Loops, Sample C Programs 82-100 6 Arrays, One Dimensional Array: Declaration and Initialization, Accessing Array Elements, Sample C Programs 101-107 7 Two Dimensional Array: Declaration and Initialization, Accessing Array Elements, Sample C Programs 108-113 8 Strings: Read & Write, Predefined Functions, Sample C Programs 114-127 9 Pointers: Declarations, Types, Pointers to Arrays, Pointers to Character Strings, Pointers to Pointers, Array of Pointers 128-141 10 Structures: Definition, Syntax, Nested Structures, Pointers to Structures, Unions: Definition, Syntax 142-151 11 Functions.
3 Definition, Syntax, Terminology, Function Declaration, Classification (Arguments and Return Type), Storage Classes, Sample C Programs 152-165 12 Parameter Passing Techniques, Passing Parameters Types, Recursion 166-176 13 Files: Definition, Opening, Closing of Files, Reading and Writing of Files, Sample C Programs 177-185 14 Binary Files, Random Accessing of Files, Enum, Typedef, Preprocessor Commands, Sample C Programs 186-199 Programming with C - Lab Prepared by IT & CSE Page 3 WEEK - 1 1 Fundamentals of computer Hardware 2 Introduction to Programming Languages & Translators 3 DOS/UNIX Commands ------------------ Fundamentals of computer Hardware Introduction to Computers The term computer is derived from the word compute , which means to calculate.
4 A computer is an electronic data processing system, which works very fast and capable of performing both arithmetic and logical functions. computer performs the following 3 operations in a sequence: 1. Accepts input data 2. Stores and processes the data in rapid speeds 3. Outputs the required information in desired format. Characteristics of a computer are: 1. responds to a specific set of instructions in a well-defined manner. 2. can execute a prerecorded list of instructions. Advantages of computers: 1. High speed: Computers have the ability to perform routine tasks at a greater speed than human beings. They can perform millions of calculations in seconds.
5 2. Accuracy: Computers are used to perform tasks in a way that ensures accuracy. 3. Storage: Computers can store large amount of information. Any item of data or any instruction stored in the memory can be retrieved by the computer at lightning speeds. 4. Automation: Computers can be instructed to perform complex tasks automatically (which increases the productivity). 5. Diligence: Computers can perform the same task repeatedly & with the same accuracy without getting tired. 6. Versatility: Computers are flexible to perform both simple and complex tasks. 7. Cost effectiveness: Computers reduce the amount of paper work and human effort, thereby reducing costs.
6 Limitations of computers: 1. Computers need clear & complete instructions to perform a task accurately. If the instructions are not clear & complete, the computer will not produce the required result. UNIT-1 Programming with C - Lab Prepared by IT & CSE Page 4 2. Computers cannot think. 3. Computers cannot learn by experience. HARDWARE computer Hardware is the physical part of a computer or physical components of the computer , including the digital circuitry, as distinguished from the computer software that executes within the hardware. It refers to the objects that we can actually touch. Ex: input and output devices, processors, circuits and the cables.
7 Organization of computer The computer consists of five functionally independent main parts: 1. Input Unit 2. Memory Unit 3. A. L. Unit 4. Output Unit 5. Control Unit INPUT UNIT: computer accepts coded information through input units and read the data. The most well known input device is keyword. Whenever a key is pressed the corresponding letter or digit is automatically translated into corresponding binary code and transmitted over a cable to the memory or the processor. Much other type of input devices includes joystick and mouse. MEMORY UNIT: The main function of the memory is to store program and data. There are two classes of storage called primary and secondary memory.
8 Programming with C - Lab Prepared by IT & CSE Page 5 RAM (Random Access Memory): It is a temporary storage and data will be erased when the system is turned off. ROM (Read Only Memory): It is a permanent memory and data will not be erased when the system is turned off. DATA STORAGE 4bits = 1 Nibble 8bits = 1 byte 1024 bytes = 1k or 1kb (kilobyte) 1024KB = 1MB (mega byte) 1024MB = 1GB (Gega byte) 1024GB = 1 TBC Terabytes Although primary storage is essential but it tends to be expensive. Thus additional, cheaper secondary storage is used. Large amounts of data and programs are stored in secondary storage.
9 : Most computer operations are executed in of the processor. stands for Arithmetic & Logical Unit. Consider a typical example: suppose two numbers located in the memory are two to be added, they are brought into the processor and the actual addition is carried out of the The sum may be stored in the memory or retain in the processor. OUTPUT UNIT: The output unit is the counter part of the input unit. Its function is to the outside world. The most typical example of such device is printer, monitor and LCD. CONTROL UNIT: CU controls the overall operations of the computer it checks the sequence of execution of instructions, and, controls and coordinates the overall functioning of the units of computer .
10 The memory unit, arithmetic & logical unit, input and output unit s store and process information and perform input and output operations. Control unit must coordinate the operations of these units. MEMORYPRIMARYRAMROMSECONDARYFLOPPY DRIVEHARD DISKCD ROMDVDFLASH DRIVEP rogramming with C - Lab Prepared by IT & CSE Page 6 SOFTWARE Software is a program or set of instructions that causes the Hardware to function in a desired way. Practical computer systems divide software into three major classes: System software helps run the computer hardware and computer system. It includes operating systems, device drivers, diagnostic tools, servers, windowing systems, utilities and more.