Thursday, 18 March 2021
Types Of Computers
Friday, 26 February 2021
Block Diagram & History of Computer
In order to solve a problem on a computer, we should first evolve a detailed and a precise step by step method of solving it such a method is called as “ALGORITHM”.
An algorithm is expressed by using a precise notation is called “PROGRAM”. The precise notation itself is called “PROGRAMING LANGUAGE”. Thus a program is needed to solve a problem on a computer.
A COMPUTER (Commonly Operated Machine Particularly Used for Trade Education Research) is a machine that can perform computations. A computation involves the following 3 components shown in the figure, this architecture is commonly called as “NEUMANN ARCHITECTURE”.
Example : Keyboard, Mouse etc..
2. OUTPUT DEVICE:
These are the devices that are used to output a computation according to our input.
Example: Display, Printers etc..
3.PROCESSING UNIT:
The CPU (Central Processing Unit) is the brain of the computing device and performs the basic processing steps a CPU typically consists of –
1.Contol Unit
2.ALU(Arthematic Logic Unit)
3.GPR(General Purpose Registrations)
4.Storage unit
5.Bus
1.CONTROL UNIT:
The control unit (CU) controls all the activities or operations which are performed inside the computer system. This unit is responsible for controlling flow of data and instructions.
2.ARTHEMATIC LOGIC UNIT (ALU) :
The arithmetic and logical unit is the combinational digital electronic circuit that can perform arithmetic operations on integer binary numbers. The outputs of ALU will change asynchronously in response to the input. The basic arithmetic and bitwise logic functions are supported by ALU.
3.GENERAL PURPOSE REGISTRATIONS (GPR) :
A CPU usually consists of finite numbers of memory cells for storing intermediate results and values.
4.STORAGE UNIT:
A storage unit is classified into two categories
1.Main or Primary memory
2.Secondary memory
1.MAIN OR PRIMARY MEMORY:
This is of a high-speed memory that stays close to the CPU programs are first loaded in the main memory and then executed usually, main memories are volatile.
Volatile: Loss of power leads to loss of data
2.SECONDARY MEMORY:
This is a low-speed memory, normally meant for offline storage of programs and data usually, Secondary memories are non-volatile.
Non-Volatile: Loss of power never leads to loss of data
5. BUS:
A BUS is a set of wires that connect the set of above components, buses are responsible for the movement of data from the input device to the output device
HISTORY OF COMPUTERS:
Essentially these are three types of calculating devices
1.Manual
2.Mechanical
3.Automatic
1.MANUAL:
The manual device was ABACUS. The abacus was invented around 600BC and In this device, the numbers are represented by the position of beads on a rack. By positioning the beads appropriately simple addition and subtraction is carried out rapidly and efficiently.
2.MECHANICAL:
The first mechanical adding machine was first invented by B. PASCAL in the year 1642. This machine has limited the computation of addition, subtraction, multiplication, and division were done on series of addition and subtraction respectively but the result was inaccurate and late.
3.AUTOMATIC:
In Automatic the following machines are used, they are
1.The MARK-1 computer was the first fully automatic calculating machine designed by Howard Aiken of Harvard University in collaboration with IBM it was very complex, huge, and very slow.
2.ENIAC machine (Electronic Numerical Integrator and Calculator)was designed by a team led by Prof J.P.Eckest & John Mauchly of the USA in 1943 . It is a Huge machine of 30 tonnes require around 18,000 Vaccum tubes performed about 5,000 additions per second and consumes 150-kilo watts of power and also requires big room for its placement.
3.EDVAC machine (Electronic Discrete Variable Automatic Computer) was designed on stored programs concept by John von Neumann. This machine was developed in 1946.
4.EDSAC machine (Electronic Delay Storage Automatic Calculator) was designed by Prof.M.Wikes at Cambridge University in 1947.
Monday, 21 December 2020
GATE Questions
1)Program:
main()
{
int a=2,b=3;
printf("%d",++(a*b+1);
}
Output: compile time error
Explanation : -- / ++(expression) will not allow
2)Program:
main()
{
int x=6;
if(x-6)
printf("welcome");
printf("%d",x);
else
printf("learner");
}
Output: error
Explanation : there is no braces for if condition
3)Program:
main()
{
int x=6;
if(x-6)
{
printf("welcome");
printf("%d",x);
}
else
printf("learner");
}
Output: learner
Explanation : if (0) means condition false so it prints learner
4)Program:
main()
{
float a=3.14;
printf("%f",a%2);
}
Output: compile time error
Explanation : float will not support % operator
5)Program:
int initializer (void)
{
return 50;
}
int main()
{
static int i=initializer();
printf("value of i =%d",i);
getchar();
return 0;
}
Output: compile time error
Explanation : In c static variables can only be initialized using constant literals
Thursday, 19 March 2020
Programs to illustrate operators
We can define operators as symbols that help us to perform specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands.
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Increment Operators
- Decrement Operators
- Assignment Operators
- Ternary or Conditional Operators
- Special Operators
Examples: (+, -, *, /, %,++,–).
Arithmetic operator are of two types:
/* Program to illustrate
#include<conio.h>
#include<process.h>
#define pf printf
#define sf scanf
void main()
{
int a,b,r;
clrscr();
pf("\n enter a value :");
sf("%d",&a);
pf("\n enter b value :");
sf("%d",&b);
r=a+b;
pf("\n Result is %d",r);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define pf printf
#define sf scanf
void main()
{
int a,b,r;
clrscr();
pf("\n enter a value :");
sf("%d",&a);
pf("\n enter b value :");
sf("%d",&b);
r=(a<b);
pf("\n Result is %d",r);
getch();
}
NOTE: Relational operators can be used to combine more than one arithmetic expressions
for example : (a+b) >(c*d)
#include<conio.h>
#include<process.h>
#define pf printf
#define sf scanf
void main()
{
int a,b,c,d,r;
clrscr();
pf("\n enter a value :");
sf("%d",&a);
pf("\n enter b value :");
sf("%d",&b);
pf("\n enter c value :");
sf("%d",&c);
pf("\n enter d value :");
sf("%d",&d);
r= (a+b)<(c*d);
pf("\n Result is %d",r);
getch();
}
|
a |
b |
a &&b |
|
0 |
0 |
0 |
|
0 |
1 |
0 |
|
1 |
0 |
0 |
|
1 |
1 |
1 |
|
a |
b |
a ||b |
|
0 |
0 |
0 |
|
0 |
1 |
1 |
|
1 |
0 |
1 |
|
1 |
1 |
1 |
|
a |
!a |
|
0 |
1 |
|
1 |
0 |
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define pf printf
#define sf scanf
void main()
{
int a,b,r;
clrscr();
pf("\n enter a value :");
sf("%d",&a);
pf("\n enter b value :");
sf("%d",&b);
r=(a&&b);
pf("\n Result is %d",r);
getch();
}
NOTE: Logical operators can be used to combine more than one relational expressions
for example : (a>b)&&(c<d)
/* Program to illustrate logical operators can be used to combine more than one relational expressions */
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define pf printf
#define sf scanf
void main()
{
int a,b,c,d,r;
clrscr();
pf("\n enter a value :");
sf("%d",&a);
pf("\n enter b value :");
sf("%d",&b);
pf("\n enter c value :");
sf("%d",&c);
pf("\n enter d value :");
sf("%d",&d);
r=(a>b)&&(c<d);
pf("\n Result is %d",r);
getch();
}
The following are the 6 Bitwise operators
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define pf printf
#define sf scanf
void main()
{
int a,b,r;
clrscr();
pf("\n enter a value :");
sf("%d",&a);
pf("\n enter b value :");
sf("%d",&b);
r=(a&b);
pf("\n Result AND '&': %d",r);
r=(a|b);
pf("\n Result inclusive OR '|': %d",r);
r=(a^b);
pf("\n Result exclusive '^': %d",r);
r=(~a);
pf("\n Result NOT '~': %d",r);
r=(a>>2);
pf("\n Result right shift '>>': %d",r);
r=(a<<2);
pf("\n Result left shift '>>': %d",r);
getch();
}
output:
/* Program to illustrate Ternary or Conditional operators */
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define pf printf
void main()
{
int a=10,b=5;
clrscr();
(a>b) ? pf("\the value of a is %d",a) : pf("\the value of b is %d",b);
getch();
}
* Program to illustrate sizeof and comma operators */
#include<stdio.h>
#include<conio.h>
#include<process.h>
#define pf printf
void main()
{
x=(a=10,b=5,a+b);
pf("\n The value of the given comma operator is %d",x);
Programs in turboc3 : Files
File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...
-
C TOKENS: The Smallest individual units are known as ‘C’ Tokens. ‘C’ as six types of tokens: 1. KEY WORDS 2. IDENTIFIERS 3. CONSTANTS 4.VARI...
-
File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...
-
Functions in c A function is a set of statements that takes input, do some specific computation and produces output. Function Declarat...




