Introduction
Computer:Computer is an electronics device that can perform various arithmetic and logical operations. It can receive data, process it and produce output. It can store large amount of data.
Block Diagram of a Computer

Functional Units of Digital Computer
A digital computer is considered to be a calculating device that can perform arithmetic operations at enormous speed.
- Input Unit:The commonly used input devices are mouse, mike, key board,scanner, optical mark reader, joy stick etc. Thus, we can conclude that, all the input devices accepts the data and instruction from outside world, convert it to a form that the computer can understand, supply the converted data to the computer system for further processing.
- Storage Unit:The storage unit of a computer holds data and instructions that are entered through the input unit, before they are processed. It stores programs, data as well as intermediate results and results for output. Its main function is to store information.
- Central Processing Unit (CPU):The control unit and arithmetic logic unit of computer are together known as central processing unit (CPU). The CPU is like brain and performs following functions: It performs all calculations, it takes all decisions, and it controls all units of a computer.
- Output Unit:An output unit performs the reverse operation of that of an input unit so it supplies information obtained from processing to outside world. Units called output interfaces accomplish this task. Example: monitor,printer,speaker,projector etc.
Difference of Low Level and High Level Language:
Low Level Language | High Level Language |
---|---|
They are faster than high level language. | They are comparatively slower. |
Low level languages are memory efficient. | High level languages are not memory efficient. |
No need of translator except assembler for AL. | Compiler & Interpreter is needed to convert HLL. |
Ex: Machine/Assembly Language | Ex: C, C++, Java |
Operating System
- An Operating System(OS) is a system program which provides an interface between computer user and computer hardware.Some popular operating systems include UNIX, Linux and Windows etc.
- Resource Manager/Allocator:An operating system is termed as resource manager ,as its provides all necessary resources to application execution inside a computer system, like to play a song, OS allocates operational mouse, monitor, speaker, ram, hard disk, buses, processor etc to application.
- Following are some of important functions of an operating System.
- Memory Management
- Processor Management
- Device Management
- File Management
- Security
Algorithm & Characteristics of Algorithm
- A step-by-step method of solving a problem or making decision is termed as algorithm.
Properties of the algorithm
- input:An algorithm has zero or more inputs.
- Output:An algorithm has one or more outputs.
- Finiteness:An algorithm must always terminate after a finite number of steps.
- Definiteness:Each step of an algorithm must be precisely defined; the actions to be carried out must be rigorously and unambiguously specified for each case.
- Effectiveness:An algorithm is also generally expected to be effective. This means that all of the operations to be performed in the algorithm must be sufficiently basic that they can in principle be done exactly and in a finite length of time.
Advantage & Disadvantages
Advantages of algorithm
- An algorithm uses a definite procedure which makes it easy to understand.
- It is not dependent on any programming language, so it is easy to understand.
- Every step in an algorithm has its own logical sequence so it is easy to debug.
- By using algorithm, the problem is broken down into smaller pieces or steps.
Disadvantages of algorithm
- Writing algorithm takes a long time.
- An algorithm is not a computer program; it is rather a concept of how a program should be.
Example of Algorithm
- Write an algorithm to find an addition of two number
step:-1 Start step:-2 input a and b step:-3 c=a+b step:-4 print c step:-5 Stop
Flowcharts and its Notations
Flowchart:-It is a diagrammatic representation of sequence of logical steps of a program. Flowcharts use simple geometric shapes to depict processes and arrows to show relationships and process/data flow.
Advantages of flowchart:
- The Flowchart is an excellent way of communicating the logic of a program.
- It is easy and efficient to analyze problem using flowchart.
- It helps the programmer to write the program code.
Disadvantages of flowchart:
- The flowchart can be complex when the logic of a program is quite complicated.
- Drawing flowchart is a time-consuming task.
- Difficult to alter the flowchart & uses special sets of symbols for every action.
Symbol | Symbol Name | Purpose |
---|---|---|
![]() |
Start/Stop | Used at the beginning and end of the algorithm to show start and end of the program. |
Process | Indicates processes like mathematical operations. | |
![]() |
Input/Output | Used for denoting program inputs and outputs. |
![]() |
Decision | Stands for decision statements in a program, where answer is usually Yes or No. |
![]() |
Connector | use to connect the flow of two of more flow charts |
![]() |
Arrow | Shows relationships between different shapes. |
Example of Flowchart:-
Flowchart of Simple Interest

Pseudo Code
Pseudocode is an informal way of programming description that does not require any strict programming language syntax or underlying technology considerations. It is used for creating an outline or a rough draft of a program. Pseudocode summarizes a program’s flow, but excludes underlying details. System designers write pseudocode to ensure that programmers understand a software projects requirements and align code accordingly.
Advantages of Pseudo Code
- Pseudocode is understood by the programmers of all types.
- It enables the programmer to concentrate only on the algorithm part of the code development.
- It cannot be compiled into an executable program.
Example:-
Average of 10 numbers:-
Set total = 0 Set I = 0 While i is less than or equal to 10 Input the next number Add the number into the total I=I+1 Set the average to the total divided by 10 Print the average
Structure of C Program
/ Sample of C Program(documentation Section) #include <stdio.h> // link section #include<conio.h> // link section #define pi 3.14 // definition section int a=10; // global variable declaration void disp(); // global function declaration void main() // main function definition { float area,r; printf(“enter radius”); scanf(“%f”,&r); area=pi*r*r; printf(“area=%f”,area); disp(); getch(); }
Characteristics of C
- C is a middle level language.
- C is structured programming language.
- It is efficient.
- It is a portable language.
- It has rich set of operators and data type.
- Emphasis is on doing things and data move freely.
Application of C
- Operating system like Windows Unix Linux are written in C.
- 3D games and device drivers are written in C.
- C programming language can be used to design the compilers.
Data Types
Data types determine the types of value and the range of values that can be stored in a variable
C support three classes of data types
- Primary data type🡪 char, int, float.
- Derived data type🡪 array, pointer.
- User defined data type 🡪 structure, union, enum.
Program of sum of three number:-
#include <stdio.h> void main () { int a, b, c, d; printf("Enter three numbers a, b & c: "); scanf("%d %d %d", &a, &b, &c); d = a + b + c; printf("Sum = %d", d); } OUTPUT Enter three numbers a, b & c : 1 2 3 Sum = 6
Diagram of if else program
If Else
The if statement alone tells us that if a condition is true it will execute a block of
statements and if the condition is false it won’t.
But what if we want to do something else if the condition is false. Here comes the C
else statement.
else is optional statement.
We can use the else statement with if statement to execute a block of code when the
condition is false.
Program of even or odd
#include<stdio.h> int main() { int n; printf("enter the no"); scanf("%d",&n); if(n%2==0) printf("%d is even number",n); else printf("%d is odd number",n); return 0; }
Switch Statement
It is a in built multiway decision system in C.
The control statement that allows us to make a decision from the number of choices
is called the switch case statement.
Rules for switch statement
- The switch case must be constant or a constant expression.
- The case label must be constant and unique.
- Case label must end with colon(:) and each statement with semi colon(;).
- Case label can be int or char constant but it cannot be float.
- Using break is compulsory but default is optional.
Syntax of switch statement:-
switch(integer exp) { case value1: block 1; break; case value2: block 2; break; case value n: block n; break; default: block x; }
Flowchart of switch statement

Program of Calculator:-
#include <stdio.h > int main() { int a,b,c,ch; printf("Enter First number:\n"); scanf("%d",&a); printf("Enter second number:\n"); scanf("%d",&b); printf("\nEnter 1 for addition:\n "); printf("Enter 2 for subtraction:\n "); printf("Enter 3 for multiply:\n"); printf("Enter 4 for division:\n "); scanf("%d",&ch); switch(ch) { default: printf("wrong input\n"); case 1 : c=a+b; printf(“sum is :%d\n",c); break; case 2 : c=a-b; printf("Sub is : %d\n",c); break; case 3 : c=a*b; printf(“Mul is%d\n",c); break; case 4 : c=a/b; printf("div is : %d\n",result); break; } return 0; }
Loops
The instructions which are used to repeat any statement multiple number of times depending on specific condition is known as repetition or looping control instructions.
Types of loops:-
- For loop
- While loop
- Do while loop
For loop
It is used to repeat the block of code, on basis of some specific condition.
Syntax
(1) (2) (3) for(initialization ; condition ; increment/decrement) { true block statement; (4) } statement x: (5)Order of execution:-
T T F 1 2 4 3 2 4 3 2 5
Program of print character 10 times:-
int i; for(i=1 ; i<=10 ; i=i+1) { printf("a"); } Output:- aaaaaaaaaa
While loop
It is used to repeat the block of code, on basis of some specific condition.
Syntax
initialization (1) while(condition) (2) { true block statement; (4) increment/decrement; (3) } statement x: (5) Order of Execution:- T T F 1 2 4 3 2 4 3 2 5
Program of print character 10 times:-
int i=1; while(i<=10) { printf("a"); i = i + 1; } Output:- aaaaaaaaaa
Do while loop
In do while the block is executed first & then the condition is checked.
Syntax:-
Initialization (1) do { true block statement; (4) increment/decrement; (3) } while(condition) (2); statement x: (5) Order of Execution:- T F 1 4 3 2 4 3 2 5