Block diagram of a computer CPU
Arithmetic and Logic unit (ALU)

Input unit

Control unit
Memory unit

Outp ut unit

1. Input unit: This is the receiving section of the computer. It obtains information from various input devices and places this information at the disposal of the other units. Most information is carried into computers today through keyboards and mouse devices. Information can also be entered by speaking to your computer and by scanning images. 2.Output unit: This is the shipping section of the computer. It takes information that has been processed by the computer and place it on various output devices to make the information available for use. Most information output from computers today is displayed on screens, printed on paper. 3.Memory unit: This is the warehouse section of the computer. It retains information that has been entered through the input devices. This memory unit also retains processed information until that information can be placed on output devices, by the output devices. This Memory unit is also called memory or primary memory. 4.Arithmetic and Logic unit (ALU) : This is manufacturing unit of the computer. It is responsible for performing calculations such as addition, subtraction, division and multiplication. It contains decision mechanisms to find the logical relation between two variables. 5.Control unit: The control unit controls all the component activities of the computer. It sends command and control signals and finds the sequence of instructions to be executed. 6.Central processing unit: Control unit, memory unit and ALU constitute central processing unit

Notes Prepared by T. Ratna Reddy.

Associate Professor, CBIT

Mobile No: 9985 666778 Page 1

2. So high-level languages are developed. printer and so on. Example: LOAD A ADD B STORE C iii) Assembly languages require translator programs. 2. Example: C = A + B. 3.C and C++ are the high level languages. High-level languages: i) To write complex programs in assembly languages is difficult.UNIT . Assemblers convert assembly language programs machine level languages. Therefore middle-level languages are developed. key board Mouse Disk drives Monitor Operating system user Applicatio n programs Three major stages of evolution of OS: 1. FORTRAN. iii) These languages do not require translators because machine code will be directly understood by the computer. ii) The instructions of these languages consists mnemonics. iv) PASCAL. Ratna Reddy. Assembly languages: i) Programming in low-level languages is very difficult. keyboard. Associate Professor. Batch processing: performing one task or job at a time. called assemblers. 3. Mnemonics are the English like abbreviations to represent the elementary operations of the computer. monitor. Machine languages: i) These are the low-level languages directly used by the computer.I OPERATING SYSTEM (OS) An operating is a program which connects the user and the electronic hardware in a computer. Time sharing system: this OS allow many users to share the computer at a time. that particular task. iii) Translator programs called compilers convert high-level language programs to machine language. ii) In these programs single statements accomplish. Notes Prepared by T. ii) The instructions of these languages consists of stings of binary digits 0 and 1. iv)These languages are machine dependent. It has a set of programs which supervise the activities of a computer and activate the operations of the hardware components such as main memory. PROGRAMMING LANGUAGES There are 3 types of programming languages 1. Multiple processing: it involves simultaneous operation of many jobs on the computer. disk drives. CBIT Mobile No: 9985 666778 Page 2 .

The compiler also reports syntax errors. Breaking down the source code into small pieces and constructing the object code. Associate Professor. The program written in high level language is called source code and the compiled program is called object code. CBIT Mobile No: 9985 666778 Page 3 . Interpreter reads source code line by line. Linker Assembler: Assembler is software that converts a program written in assembly language into machine code.UNIT . Interpreter. The compilation process generally involves two parts. Compiler is software that translates the program written in high level language to machine language.e. Source code Assembler Interpreter Compiler Object code Linker: A linker is a program that link several object modules and libraries to form a single executable program. binary form. executes the line.I Assembler. Loader. converts it into machine understandable form. There is usually one-to-one correspondence between simple assembly statements and machine language instructions. and then proceeds with the next line. Compiler. Interpreter: Interpreter performs line by line execution of the source code. if any in the source program. Source program Compiler Object code Linker Memory Loader Executable code Notes Prepared by T. Ratna Reddy. Since the machine language is dependent on the processor architecture. assembly language programs also defer for different architecture. Loader: Loaders are a part of operating system that brings an executable file residing on disk into memory and starts it running. Some languages that uses interpreter are BASIC and PYTHON Compiler: A program written in high level language has to be converted to a language that computer can understand i.

E.depending on the number of digits used(radix).I Number systems There are four types of number systems . 3.no 1.UNIT .B. to represent a number. Name of number system Decimal number system Binary number system Octal number system Hexadecimal number system Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Numbers used 0 to 9 0 and 1 0 to 7 0 to 9. CBIT Mobile No: 9985 666778 Page 4 .A. Associate Professor. s.F octal 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 Radix or base 10 2 8 16 hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F Notes Prepared by T. 2.C.D. 4. Ratna Reddy. The base or radix of a number system is defined as the number of digits that it uses to represent the number.

I Binary to decimal 1101012 = ( )10 Octal to decimal 4688 = ( )10 Hexadecimal to decimal ABC16 = ( )10 Decimal to binary 12510 = ( 1111101) 2 Decimal to Octal 123410 = ( 2322)8 Decimal to Hexadecimal 123410 = ( 4D2 ) 16 Hexadecimal to Binary 10AF16 = ( )2 Octal to Binary 7058 = ( )2 Technique: Convert each Technique: Convert each hexadecimal Octal digit to a 3-bit digit to a 4-bit equivalent binary equivalent binaryCBIT Notes Prepared by T.UNIT . Ratna Reddy. Associate Professor. representation representation Octal to Hexadecimal 10768 =( )16 Technique: Use Mobile No: 9985 666778 Page 5 binary as an intermediary .

UNIT .0 1 Therefore 0.375 X2 = 0.I Floating point representation To convert a decimal fraction to another base b.5X 2 = 1.6875 X 2 = 1.375 1 0. Associate Professor. CBIT Mobile No: 9985 666778 Page 6 . By following the steps one should get the final result. Flow chart uses various geometrical figures to represent the operations and arrows to show the direction of flow. The steps must be clear and definite.10112 Input/output Algorithms and flow charts: Processing Algorithm is a step by step process to do a particular task. Start/stop Checking/decision making Looping Connector Arrows to represent direction of flow Notes Prepared by T.687510 to binary.75X 2 = 1. Ratna Reddy. Following are the commonly used symbols in flowcharts. repeated multiplication by base b is done instead of division. Decimal to binary Multiplication process integer part 0. Let us take an example that converts a decimal fraction 0.750 0 0.5 1 0. Flow chart is the pictorial representation of an algorithm.687510 = 0.

Lowercase letters Numbers: 0 to 9 a to z Special characters: + . Valid abhilash sum product abc123 ab__12__cd hyderabad (first 8 are recognized) Uppercase letters A to Z Invalid 23abc _2cd P. whenever you write programs. • These key words names should not be used in function names or variable names or identifiers. Maximum number of characters should not excess 8 (excess are ignored). • Keywords serve as basic building blocks for program statements.UNIT . 2. • No gap should be left in between the letters of a single key word. 4. all these keywords must be used in lower cases. Keep this list with you for reference. They can be for variable name function name so on. are user-defined words.N. USER DEFINED WORDS Notes Prepared by T. Variable ‘b’ is of type float we can store only integer values in ‘a’ but not int. while using. Second character on wards alphabets. Variable ‘a’ is of type int we can store only integer values in ‘a’ but not float. • All these keywords are in lower case letters. • Each keyword has a special meaning in C.cd ab-cd auto Rules of user defined words 1. which are defined by user. 5. As capital or upper case letters and lower case letters are significant in C. • These key words are also called as reserved words or vocabulary for the language. It must start with an alphabet. No special characters are allowed expect underscore. rao Rama rao ab. Associate Professor. .V. . 3. digits or underscore’s can be used. CBIT Mobile No: 9985 666778 Page 7 .I CH AR AC TE RS US ED IN C Aph abe ts: The words. :‘ “ & # $ ^ < > = ( ) [ ] { } _ KEY WORDS char double unsigned continue extern if void while switch goto else const int short for auto struct volatile enum float signed break static union default long do case return sizeof register MEMORY CONCEPTS AND DATATYPES Data type is defined as the type of value that can be stored in a variable EXAMPLE int a. It cannot be a reserved word. Ratna Reddy.* / \ % |~? !. float b.

There is no sign bit is sign bit. 6. Minimum value of unsigned integer is 0. char Int (2B) long unsigned (4B) (2B) 1.I There are several data types in C language. First 26 bits are integer part and next 6 bits are for fractional part. unsigned char: It takes 1B of memory space that is 8 bits. Maximum value is 27 – 1 = 127. 2. all 8 are magnitude bits. CBIT Mobile No: 9985 666778 Page 8 . signed char(or) char: It takes 1B of memory space that is 8 bits.xxx ^ xxxxxx x→ 0 or 1 26 6 Notes Prepared by T. 1 010 1100 0101 0010 sign magnitude signed char If the sign bit is zero it is +ve magnitude. int k = ‘z’. It is an extension to Integer it takes 4B of memory space that is 32 bits. unsigned int : It takes 2B of memory space that is 16 bits. Decimal point is assumed after 26th bit. That is Conversion of int to float. Minimum integer value is -215 = -32768 Thus integer ranges from –32768 to 32767. int to char so on is called type casting. 1.long double: It takes 10B of memory space. int 5. float float value is type casted to int so a = 10. char ch = 65. int a = 10..minimum value is 0. Range of ASCII values is from 0 to 255 8. It is not stored in memory xxxxxxxx…. float : It takes 4B of memory space. Maximum value of long integer value is 231 – 1 unsigned char (1B) (1B) 7. 1. It is not stored in memory. Maximum value is 28 – 1 = 255. Implicit type casting Type casting is done by system. Ratna Reddy. float b = 25. Associate Professor. Decimal point is assumed after 52th bit.0 3. We cannot represent –ve values in unsigned character Type casting Conversion of one data type to some other data type is known as type casting. Maximum integer value is 215 – 1 = 32767.UNIT . First bit is sign bit and remaining 31 are magnitude bits. int value is type casted to char so that ch = A. First 52 bits are integer part and next 12 bits are for fractional part.8. There is no sign bit. First 65 bits are integer part and next 15 bits are for fractional part. float (4B) double long double (8B) (10B) 4. If the sign bit is 1 it is -ve magnitude. 2. 4. First bit is sign bit and remaining 15 are magnitude bits.int: It takes 2B of memory space that is 16 bits. Decimal point is assumed after 65th bit. Minimum value is –27 = -128 3.8 is ignored. . Maximum value unsigned integer is 216 – 1 = 65535. long int: To represent a value more than 32767 long is used. All 32 bits are magnitude bits. float to int. There is one sign bit and 7 are magnitude bits are magnitude bits. int value is type casted to float so b = 25. double (long float): It takes 8B of memory space.

They become 9 and 5. where v1. to display integer value 2.5 Variable a is of type. ASCII value of z.0/2 = 3.sum). Ratna Reddy. Control string is the format string which represents the format specification data type format specifier // To find the sum of two numbers #include <stdio.9. = 7. So they must be type casted to int. v2. scanf(“%c”.v2 are variables whose values are to be displayed on the screen.&ch).sum.0 . → It is declaration statement. int float char string %d %f %c %s Examples 1. scanf(“%f”. scanf(“%d%f”. (float)a/b).… are variables whose values are to be read from the keyboard. They are type casted to int. to read integer value 2.v1. It is call by address function.I character is type casted to int so k = 90. to read char value 4. CBIT Mobile No: 9985 666778 Page 9 .&v1. Where v1. scanf(“%s”. It is an input function. 1.x). = 9 %5 = 4 Variables a and b of type float.0 = 3. scanf(“%d”.x). to read an integer value and a float value.…&vn).&x. (int)a%(int)b). Type casting is done by programmer.&v2. float a = 9.&x.&x). b = 2.UNIT .…vn). printf (“%d”. We must send address to scanf but not variable It has the following form scanf(“format string”. to read float value 3. int a. int a = 7. 2. it is type casted to float so ‘a’ becomes 7. to display float value 3. Thus type casting is not for entire program a/b is 3.name).5 2. Basic Input and output functions printf() Function print() function is used to display a string or values of variables using the standard output device(monitor).5 a/(float) b = 7/2. printf(“the result is %d”.y.h> void main() { int x. printf(“%d”. sum = x+y. Explicit type casting. The value of ‘a’ continues to be 7 in the rest of the program. a % b is error since %is integer operator. to read a string 5.&a). printf("the sum of %d and %d is %d\n”.&a). Associate Professor. It has the following forms printf(“control string”).a). x. printf (“%f”. Examples 1. printf(“%f”.8 . scanf("%d%d". scanf() Function scanf() function is used to read/input values of variables using the standard input device(keyboard).v2.y. (float)a/b = 3. printf(“control string”. b = 5. printf("Enter two numbers\n"). (int) a is type casting.&y). } Notes Prepared by T.

5. 14.I S. No 1. 9. 10. 18. 2. 11. 16. 12. CBIT Mobile No: 9985 666778Page 10 . 17.UNIT . unsigned int unsigned int unsigned int unsigned int long int short int unsigned long unsigned short float float float float float double string type %o %u 6. Associate Professor. %ld %hd %lu %hu %f %e %E %g %G %lf %s Notes Prepared by T. 3. Data Type char Int int Format specifier %c %i %d Remark Signed character Signed integer Signed integer in decimal number system Unsigned integer in octal number system Unsigned integer in decimal number system Unsigned integer in hexadecimal number system Unsigned integer in hexadecimal number system Signed long Signed short Unsigned long Unsigned short Signed single precision Signed single precision in e format(exponent) Signed single precision in E format(exponent) Signed value either in e or f format Signed value either in E or F format Signed double precision float string 4. %x 7. 13. %X 8. Ratna Reddy. 15.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.