Chapter 1: Introductory Concepts Dr. Ameer Ali
Overview Introduction to computers Computer characteristics Modes of operation Types of programming languages Introduction to C Sample C program Chapter 5: Preparing and running a complete C programming
Introduction to Computers History
Computer Characteristics Basically electronic devices that can transmit, store, and manipulate information Different types of data can be processed by a computer Numeric data, character data, graphic data, sound. To process a set of particular data, the computer must be given an appropriate set of instructions called program. This program is entered into the computer and then stored into memory.
Computer Characteristics A stored program can be executed at any time and followings are happen: Input data is entered into the computer Input data are process to get desired result or output Processed output can be displayed into the monitor
Memory Stored as 0 and 1 and known as bit (binary digit) 8 bit is one bit 2 10 Byte= 1024 byte=1KB 2 10 KB= 1024 KB=1MB 2 10 MB= 1024 MB=1GB
Speed and Reliability High speed and takes approximately sec for one instruction High reliable and can never mistake with its own accord
Modes of Operation Batch Processing Time sharing Interactive Computing: commercial time sharing
Types of Programming Language Low level: machine language Very detailed, cryptic instructions that control computer’s internal circuitry Very few computer programs are written in machine language due to: (i) very cumbersome to work with it and (ii) different type of computers has its own instructions High Level: C language Compatible with human language
High Level: C language Compatible with human language Significant advantages over machine language: simplicity, uniformity and portability i.e. machine independence
Introduction to C Structured programming languages Developed in 1970’s at bell telephone laboratories Confined until 1978 and then published After this, development of computer grown rapidly Used for system programming and application programming
Introduction to C Large number of operators included with C and ability to write very concise source program Features and capabilities can easily be extended Available for all size computers Highly portable
Structure of C program Include header file Define constant values Write Main program
Sample C program Add two numbers a and b #include void main (void) {int a, b, sum; printf(“take input for a=“); scanf(“%d”,&a); printf(“take input for b=“); scanf(“%d”,&b); sum=a+b; printf(“The sum is sum=“, sum); getch(); }
Preparing and Running Save it into specific directory as test.cpp Compile and check error Cursor will indicate where the error is After successful compilation, run from the toolbar or ctrl+F9 Give proper input if required and then you will get output
Preparing and Running If the program is not giving you the proper output, then debug program using debugger. Practice: Calculate P=C(1+i) n Calculate addition, subtraction, multiplication, and division