You are on page 1of 51

Generations of Computer

 What generation a computer belongs to is determined by the technology it


uses.
 This table shows “Technology used in different generations of computers “.
Classification of Computer

Computer

Based on Based on Based on


Operating Principles Applications Size & Capabilities

1. Analog 1. Special 1. Micro


Computers Purpose Computers
2. Digital Computers 2. Mini
Computers 2. General Computers
3. Hybrid Purpose 3. Mainframe
Computers Computers Computers
4. Super
Computers
Basic organisation of computer

I/P UNIT MEMORY O/P UNIT


UNIT

CACHE MEMORY

Block Diagram of
REGISTERS a Computer
System

ALU

CONTROL
UNIT
Example
• Binary to decimal conversion
11001.001
1X2-3 = 0.125
0X2-2 = 0
0X2-1 = 0
1X20 = 1
0X21 = 0
0X22 = 0
1X23 = 8
1X24 = 16
25.12510
Algorithm
• Addition of two numbers
Step1: Start
Step2: Read a, b
Step3: Add the value of a with b and store
the result in c.
Step4: Display the value of c
Step5: Stop
Flowchart Symbols
• Terminal symbol
– It is used to represent the start, end of the
program logic.

• Input/Output
– It is used for input or output.

• Process Symbol
– It is used to represent the calculations, data
movements, initialization operations etc,.
• Decision Symbol

– It is used to denote a decision to be made at that


point

• Flow lines
– It is used to connect the symbols

• Connectors
– It is used to connect the flow lines.
9
Pseudocode
Guidelines
• Steps should be understandable
• Capitalize the keyword.
• Indent to show hierarchy.
Keywords
• READ,GET
• PRINT,DISPLAY
• COMPUTE,CALCULATE
FIGURE 2-2 Structure of a C Program

11
Different Operators
FIGURE 2-11 Variables

13
PROGRAM 2-7 Calculate a Circle’s Area and Circumference

Computer Science: A Structured


14
Programming Approach Using C
PROGRAM 2-7 Calculate a Circle’s Area and Circumference (continued)

15
Control Statements Include
Selection Iteration Jump
Statements Statements Statements
• if • for • goto

• if-else • while • break

• switch • do-while • continue

• return
if...else

17
The Conditional Operator
• It has the following simple #include <stdio.h>
int main()
format: {
int a,b,c;
printf(“\n ENTER THE TWO NUMBERS:”);
expr1 ? expr2 : expr3
scanf(“%d %d”, &a, &b);
c=a>b? a : b>a ? b :-1;
It executes by first evaluating if(c==-1)
printf(“\n BOTH NUMBERS ARE
expr1, which is normally a EQUAL”);
relational expression, and else
then evaluates either expr2, printf(“\n LARGER NUMBER IS %d”,c);
return 0;
if the first result was true, or }
expr3, if the first result was
false.
An Example
else-if

19
Switch … case

20
while loop

21
For Loop

Computer Science: A Structured


22
Programming Approach Using C
Comparing for and while Loops

23
while vs. do..while Loops

24
break and Inner Loops

25
One Dimensional Array

26
Declaring and Defining Arrays

27
Two-dimensional Array

28
2D Memory Representation

29
Strings

30
Defining Strings

31
String Manipulation
String Comparison

33
String Concatenation

34
Bubble Sort Example

35
Binary Searching
• Consider the array 1 2 3 4 5 6 7 8 9
• Construct the binary search algorithm for finding the Key = 7.
• 1st iteration
– HIGH = 8, LOW = 0; because the array index begins with ‘0’ and ends with ‘8’.
MID = 4, Array[4] = 5, 5<7 : TRUE
LOW = 5
New List = 6 7 8 9
Function Definition

37
Function with Parameters

38
Parts of a Function Call

39
Factorial (3) Recursively

40
Recursive Factorial Function

41
Pointer Variable

42
Initializing Pointer Variables

43
Pass-by-value

44
Pass-by-Reference

45
Arrays and Pointers

46
Structures

47
Structure Format

48
Structure Direct Selection Operator

49
Nested Structure

50
Unions

51

You might also like