C PROGRAMMING NOTE
Based on the syllabus of Final B.Sc. Mathematics (Calicut University)
By
T K Rajan Selection Grade Lecturer in Mathematics Govt. Victoria College, Palakkad Phone: 9446537545
2
Contents
1 2 3 4 5 6 7 8 9 10 11 Introduction C Fundamentals Operators and Expressions Data Input Output Control Statements Functions Arrays Program structure Pointers Structures and Unions Datafiles 3 11 17 21 25 32 35 42 44 47 53
3
INTRODUCTION
Computer Basically it is a fast calculating machine which is now a days used for variety of uses ranging from house hold works to space technology. The credit of invention of this machine goes to the English Mathematician Charles Babbage. Types of Computers: Based on nature, computers are classified into Analog computers and Digital computers. The former one deals with measuring physical quantities ( concerned with continuous variables ) which are of late rarely used. The digital computer operates by counting and it deals with the discrete variables. There is a combined form called Hybrid computer, which has both features. Based on application computers are classified as special purpose computers and general computers. As the name tells special computers are designed to perform certain specific tasks where as the other category is designed to cater the needs of variety of users. Basic structure of a digital computer
The main components of a computer are Input unit (IU), Central Processing unit (CPU) and Output unit (OU). The information like data ,
4
programs etc are passed to the computer through input devices. The keyboard, mouse, floppy disk, CD, DVD, joystick etc are certain input devices. The output device is to get information from a computer after processing . VDU (Visual Display Unit), Printer, Floppy disk, CD etc are output devices.
The brain of a computer is CPU. It has three components- Memory unit, Control unit and Arithmetic and Logical unit (ALU)- Memory unit also called storage