Sunday, August 24, 2014

1.1.3 BLOCK DIAGRAM OF COMPUTER (FUNCTIONAL COMPONENTS OF COMPUTER)


A computer is a programmable device and has its own architecture. This architecture consists of three main functional units, namely:

·         Input unit
·         System Unit
·         Output Unit

 

CPU: Central Processing Unit                                                            CU: Control Unit
ALU: Arithmetic & Logical Unit                                                       MU: Memory Unit

 
Fig 02: Block Diagram of Computer

 
Input Unit
·         It is an external device that is connected to the CPU.
·         It is used to feed data and instructions for solving the problem at hand.
·         The control unit sends signal to this unit to receive data and instructions from the user, which is communicated to the CPU.
·         Examples: Keyboard, Mouse, Joystick, Scanner, Trackball, Light Pen, Touch screen, Touch pad, Bar code reader, Microphone, etc.

Output Unit
·         This is used to display the result obtained after execution of a program.
·         Whenever the user wants the output from the computer, the control unit sends signal to this unit to be ready to accept processed data from memory and display it.
·         Examples: Monitor, Printer, Scanner, Plotter, Speaker, Headphones, Fax, etc.

 System Unit
·         The data and instructions obtained from input unit are processed by the system unit.
·         It is regarded as the brain of the computer and it provides the fundamental commands and instructions for the working of the computer.
·         It is sub-divided into two:
o   CPU (Central Processing Unit)
§  CPU fetches program instructions from RAM (input), interprets and processes it (execution) and then sends back the computed results so that the relevant components can carry out the instructions.
§  It is further divided into two components:
·         ALU (Arithmetic & Logical Unit)
o   All calculations are carried out in the ALU.
o   It consists of electronic circuitry which performs the basic arithmetic operations like +, -, *, /.
o   It also consists of electronic circuitry that performs logical operations are gives us results in the form of true or false.

·         CU (Control Unit)
o   It controls and co-ordinates the activities of all the units of a computer system.
o   It acts as the central nervous system of the computer.
o   It controls and times signals to various units to co-ordinate for the specific operation.

o   MU (Memory Unit)
§  This is a storage device of the computer.
§  It stores the data and instructions fed by the user and also the result which is produced after processing the same data.
§  There are two types of memory, one is called volatile memory and the other is non-volatile memory.
In volatile memory, information is retained as long as power is supplied to the chips. In non-volatile memory, information is retained, even though power is not supplied.

 
 Fig 03: Hierarchy Chart of Memory


Ø  CPU Registers
o   A register is a small amount of storage available as part of a digital processor, such as a CPU. 
o   They can be accessed more quickly.
o   Computers load data from a larger memory into registers where it is used for calculations, manipulations, or tested, by some machine instruction. 

Ø  Main Memory

o   RAM (Random Access Memory)
§  It is a temporary storage medium in a computer.
§  All data to be processed by the computer are transferred from a storage device or keyboard to RAM during data processing. Results obtained from executing any program are also stored in RAM.
§  RAM is a volatile memory.

o   Cache Memory
§  The internal processing speed of a computer is very fast compared to the reading and writing from/to disk. During the time of reading from disk the CPU is idle. To reduce this waiting time and increase the processing speed, a cache memory is used in the computer.
§  Cache memory is a part of RAM that holds the data, which is needed next by the CPU.
§  The size of cache memory is 512 KB.

o   ROM (Read Only Memory)
§  Read Only Memory is a permanent storage medium which stores start up programs. These programs which are loaded when computer is switched on.
§  ROM stores essentially the BIOS (Basic Input Output System) programs which are recorded by the manufacturer of the computer system.
§  ROM is non-volatile memory. 

Ø  Secondary Memory
o   This is a permanent memory.
o   It stores large amount of information for a long time
o   It is also called backup memory or auxiliary memory.
o   It is connected to CPU.
o   Examples: Hard disk, Floppy disk, CD, DVD, Magnetic Tape, Flash memory, Jump drive, Pen drive, Cloud storage etc.

1.1.2 BASIC OPERATIONS OF COMPUTER


All the computers perform the following five basic operations:-

  1. Inputting: The process of entering data and instructions into the computer system.
  2. Storing: Saving data and instructions to make them readily available for initial or additional processing, as and when required.
  3. Processing: Performing arithmetic operations (add, subtract, multiply, divide etc) or logical operations (comparisons like equals to, less than, greater than etc.) on data, to convert them into useful information.
  4. Outputting: The process of producing useful information or results for the user, such as a printed report or visual display.
  5. Controlling Directing the manner and sequence in which all of the above operations are performed. The basic computer organization remains the same for all computer systems.

Saturday, August 23, 2014

1.1.1 INTRODUCTION TO DIGITAL COMPUTER


 Definition of Computer

A Computer is an electronic device that takes data and instructions as an input from the user, processes that data, and provides useful information as output.

 
The activity of processing data using a computer is called data processing. Thus, computer is also known as data processor. Data processing consists of three sub-activities:-

·         Capturing the input data (Input).
·         Manipulating the data (Processing).
·         Managing the output result (Output).

 

Fig 01: Computing Process

CHARACTERISTICS OF COMPUTER

The power and usefulness of computer is due to its following characteristics:-
 
  1. Automatic:
A machine is said to be automatic, if it works by itself without human intervention. Computers are automatic machine because once started on a job, they carry on until the job is finished, normally without any human intervention.

  1. Speed:
A computer is a very fast device. It can perform in a few seconds, the amount of work that a human being can do in an entire year if he worked day and night and did nothing else. While talking about the speed of computers, out units of speed are micro seconds (10-6), the nanoseconds (10-9) and even the picoseconds (10-12).

  1. Accuracy:
The accuracy of computer is consistently high and the degree of accuracy of a particular computer depends upon its design. Errors can occur in a computer. However, these are mainly due to human rather than technological weaknesses. 

  1. Diligence:
Unlike human beings computer is free from monotony, tiredness and lack of concentration. It can continuously work for hours, without creating any error. If ten million calculations have to be performed, a computer will perform the tenth millionth calculation with the same accuracy as the first one.

  1. Versatility:
Versatility is one of the most wonderful things about the computer. One moment it is preparing the results of an examination, the next it is busy preparing electricity bills and in between, it may be helping an office secretary to trace an important letters in seconds.

  1. Power of remembering:
A computer can store and recall any amount of data or information because of its secondary storage (a type of detachable memory) capability. Every piece of information can be retained as long as desired by the user, and can be recalled, as and when required. Even after several years, the information recalled would be as accurate as on the day it was fed into the computer. A computer forgets or loses information when it is asked to do so.

  1. No I.Q. :
A computer is not a magical device. It possesses no intelligence of its own. Its I.Q. is zero, at least until today. It has to be told, what to do and in what sequence. Hence, only the user can determine what tasks a computer will perform.

  1. No feelings:
Computers are devoid of emotions. They have no feelings and no instincts because they are machines. Although men have succeeded in building a memory for the computer, but no computer possess the equivalent of a human heart and soul. Their judgment is based on the instructions given to them in the form of programs that are written by us.

 

1.1 BASICS OF COMPUTER


The word computer comes from the word “compute”, which means to “calculate”. Hence, a computer is normally considered to be a calculating device, which can perform arithmetic operations at enormous speed.

Monday, June 18, 2012

To check whether the entered character is vowel or not, using Switch statement


/* To check whether the entered character is vowel or not, using Switch statement */

#include<stdio.h>

#include<conio.h>

void main()

{

  char ch;

  clrscr();

  printf("\nEnter an alphabet: ");

  scanf("%c",&ch);

  switch(ch)

  {

    case 'a':

    case 'A':

    case 'e':

    case 'E':

    case 'i':

    case 'I':

    case 'o':

    case 'O':

    case 'u':

    case 'U':

      printf("%c is a Vowel!",ch);

      break;

    default:

      printf("%c is NOT a Vowel!",ch);

  }

  getch();

}

 

OUTPUT-1

Enter an alphabet: A

A is a Vowel!

 

OUTPUT-2

Enter an alphabet: d

d is NOT a Vowel!

 

To print the area of geometrical figure using Switch statement


/* To print the area of geometrical figure using Switch statement */

#include<stdio.h>

#include<conio.h>

void main()

{

  int choice;

  float a,b,area;

  clrscr();

  printf("\nGiven choices are:\n");

  printf("\n1-Circle");

  printf("\n2-Square");

  printf("\n3-Triangle");

  printf("\n4-Rectangle");

  printf("\n\nEnter your choice: ");

  scanf("%d",&choice);

  switch(choice)

  {

    case 1:

      printf("\nEnter the radius of circle: ");

      scanf("%f",&a);

      area=3.142*a*a;

      printf("\nArea of Circle=%f",area);

      break;

   case 2:

      printf("\nEnter the side of square: ");

      scanf("%f",&a);

      area=a*a;

      printf("\nArea of Square=%f",area);

      break;

   case 3:

      printf("\nEnter the base and height of triangle: ");

      scanf("%f%f",&a,&b);

      area=a*b/2;

      printf("\nArea of Triangle=%f",area);

      break;

   case 4:

      printf("\nEnter the length and breadth of rectangle: ");

      scanf("%f%f",&a,&b);

      area=3.142*a*a;

      printf("\nArea of Circle=%f",area);

      break;

   default:

     printf("Given choice does not exist!!!\n");

     break;

  }

  getch();

}

 

OUTPUT

 

Given choices are:

 

1-Circle

2-Square

3-Triangle

4-Rectangle

 

Enter your choice: 3

 

Enter the base and height of triangle: 40 32

 

Area of Triangle=640.000000

 

To implement simple calculator using Switch statement


/* To implement simple calculator using Switch statement */

#include<stdio.h>

#include<conio.h>

void main()

{

  float a,b;

  char op,c;

  clrscr();

  printf("\nType in your expression\n");

  scanf("%f %c %f",&a,&op,&b);

  switch(op)

  {

    case '+':

      printf("%f\n",a+b);

      break;

   case '-':

      printf("%f\n",a-b);

      break;

   case '*':

      printf("%f\n",a*b);

      break;

   case '/':

      printf("%f\n",a/b);

      break;

   default:

     printf("Unknown operator!!!\n");

     break;

  }

  getch();

}

 

 

OUTPUT

Type in your expression

7+9

16.000000