Sunday 20 December 2015

C PROGRAMMS


1) WRITE A C PROGRAMM TO DISPLAY ANY MESSAGE?
#include<stdio.h>
#include<conio.h>
Void main()
{
clrscr();
printf(“WELCOME TO C LAB”);    //YOU CAN WRITE ANY MSG
getch();
}

2) WRITE A C PROGRAMM TO ADD, SUB, MUL OF TWO NUMBERS BY TAKING VALUES AS INPUT?
#include<stdio.h>
#include<conio.h>
Void main()
{
int a,b,c;
clrscr();
printf(“enter 1 st value”);
scanf(“%d”,&a);
printf(“enter 2 nd value”);
scanf(“%d”,&b);
c=a+b;
printf(“ADDITION OF GIVEN NUMBERS %d AND %d IS %d”,a,b,c);   
c=a-b;
printf(“SUBTRATION OF GIVEN NUMBERS %d AND %d IS %d”,a,b,c);
c=a*b;
printf(“MULTIPLICATION OF GIVEN NUMBERS %d AND %d IS %d”,a,b,c);
getch();
}

3) WRITE A C PROGRAMM TO MULTIPLY ANY TWO DECIMAL VALUES BY TAKING AS INPUT?
#include<stdio.h>
#include<conio.h>
Void main()
{
float a,b,c;
clrscr();
printf(“enter 1 st value”);
scanf(“%f”,&a);
printf(“enter 2 nd value”);
scanf(“%f”,&b);
c=a*b;
printf(“MULTIPLICATION OF GIVEN NUMBERS %f AND %f IS %f”,a,b,c);
getch();
}






4) WRITE A C PROGRAMM TO FIND GIVEN NUMBER IS EVEN OR ODD?
#include<stdio.h>
#include<conio.h>
Void main()
{
int n;
clrscr();
printf (“enter any value”);
scanf(“%d”,&n);
                if ((n%2)==0)
                 printf(“given value %d is EVEN”,n);
                else
                 printf(“given number %d is ODD”,n);
getch();
}

5) WRITE A C PROGRAMM TO PRINT NUMBERS FROM 1 TO 100 USING WHILE LOOP?
#include<stdio.h>
#include<conio.h>
Void main()
{
int i=1;
clrscr();
          while(i<=100)
          {
          Printf(“%d \n”,i);//(\n) is used to print numbers in new line
          i++;
          }
getch();
}

6) WRITE A C PROGRAMM TO PRINT NUMBERS FROM 10 TO 1 USING FOR LOOP?
#include<stdio.h>
#include<conio.h>
Void main()
{
int i;
clrscr();
          for(i=10;i>=1;i--)
          {
          Printf(“%d \n”,i);//(\n) is used to print numbers in new line
           }
getch();
}





7) WRITE A C PROGRAMM TO SWAP NUMBERS USING FUNCTION?
#include<stdio.h>
#include<conio.h>
Void swap (int,int); //function declaration with parameters and no return value
Void main ()
{
int a,b;
clrscr();
printf(“enter 1 st value”);
scanf(“%d”,&a);
printf(“enter 2 nd value”);
scanf(“%d”,&b);
swap(a,b);  //function call
getch();
}       
            Void swap(int x,int y)
{
int c;
            Printf(“VALUES BEFORE SWAPING A=%d AND B=%d”,x,y);
            c=X;
            X=Y;
            Y=c;
            Printf(“VALUES AFTER SWAPING A=%d AND B=%d”,x,y);
            }


8) WRITE A C PROGRAMM TO STORE 10 VALUES IN ARRAY AND TO PRINT THEM AS OUTPUT?
#include<stdio.h>
#include<conio.h>
Void main()
{
int i;
int a[10];
clrscr();
            for(i=0;i<10;i++)
            {           
Printf(“ENTER %d NUMBER \n”,i+1);
Scanf(“%d”,&a[i]);
            }
                        for(i=0;i<10;i++)
                        {        
Printf(“YOU ENTERED NUMBERS ARE %d \n”,a[i]);
                        }
getch();
}





9) WRITE A C PROGRAMM TO FIND SMALLEST OF ‘N’ GIVEN NUMBERS?
#include<stdio.h>
#include<conio.h>
Void main()
{
int i,n,temp;
int a[20];
clrscr();
printf(“ENTER TOTAL NUMBER OF DIGITS”);
scanf(“%d”,&n);
            for(i=0;i<n;i++)
            {           
Printf(“ENTER %d NUMBER \n”,i+1);
Scanf(“%d”,&a[i]);
            }
                         temp=a[0];
                        for(i=1;i<n;i++)
                        {        
if(a[0]>a[i])
temp=a[i];
}
Printf(“SMALLEST NUMBER IS %d \n”,temp);               
getch();
}

10) WRITE A C PROGRAMM TO FIND SUM OF “N” NATURAL NUMBERS?
#include<stdio.h>
#include<conio.h>
Void main()
{
int  n,sum=0;
clrscr();
printf(“ENTER LAST NUMBER TO FIND SUM ”);
scanf(“%d”,&n);
            for(i=1;i<n;i++)
            {           
Sum=sum+i;
            }
Printf(“SUM OF %d NUMBER IS %d \n”,sum);                
getch();
}






11) WRITE A C PROGRAMM TO FIND FIBNOCI NUMBER OF GIVEN INPUT?
#include<stdio.h>
#include<conio.h>
Void main()
{
int  n,sum=1;
clrscr();
printf(“ENTER LAST NUMBER TO FIND SUM ”);
scanf(“%d”,&n);
            for(i=1;i<n;i++)
            {           
Sum=sum*i;
            }
Printf(“FIBNOCII OF %d NUMBER IS %d \n”, sum);                  
getch();
}

12) WRITE A C PROGRAMM TO FIND SUM OF THE SQAURE OF “N” NATURAL NUMBERS?
#include<stdio.h>
#include<conio.h>
#include<math.h>
Void main()
{
int  n,sum=0;
float a;
clrscr();
printf(“ENTER LAST NUMBER TO FIND SUM ”);
scanf(“%d”,&n);
            for(i=1;i<n;i++)
            {           
Sum=sum+i;
            }
Printf(“SUM OF %d NUMBER IS %d \n”,sum);                
            a=sqrt(sum);
Printf(“SUM OF SQUARE OF %d NUMBER IS %d \n”,a);         
getch();
}


Friday 18 September 2015

Basic of Computer

COMPUTER DEFINATION :

      Computer is a modern electronic device which takes input from the user and process the input and gives accurate output to the user.

Block Diagram :
  The main parts of the computer are 
1) Input devices
2) Output devices
3) Central processing Unit
4) Memory.


Input device: Input devices are the Hardware components of computer system which are used to give input like characters, numbers and symbols etc to the computer system.
Example: Keyboard. Mouse (It is used in graphical representation).

Output device: Output devices are the Hardware components of the computer system which are used to give output to the users from computer.
Example:
1)      If out put is soft copy then we use Monitors
2)      If out put is Hard copy we use Printers.

Memory: Memory is a Magnetic Hard ware Material which is used to store the data in the form of Bits (Which is a Machine Language).It is measured in the form of unit called “byte”.
Example: RAM ROM, Hard Disk, CD, Floppy etc.Memory is measured in bytes like kilobyte(kb),Megabyte(mb),Gigabyte(gb).....

Central Processing Unit (CPU): CPU is Main part (Heart) of Computer system which is also a Hardware component.CPU is mainly consists of three parts, it contents Hardware components like Registers, transistors, Circuits etc.

a) Arithmetic and Logic unit: This is used to perform all Mathematical Calculations and all decision making operations.

b) Control Unit: It is a main part which control all CPU Signals, Memory signals etc.It controls both hardware and software components of computer system.

c) Memory Unit: This is used to store the data.

Computer History:
Computers are the machines which are designed to perform large calculation and to store data. In olden days for calculations people use their fingers for calculations, and then they develop Abacus like Chinese Abacus, Russian Abacus etc…

In Early 1820’s A Mechanical Engineer designed a calculating Machine which is mechanical and this is our First Computer Machine which performed calculations of large size. He is FATHER OF COMPUTER named “Charles Babbage”.
Many changes were done to this computer from mechanical to electrical and then Analog  to Digital .

Computer history is mainly divided into Generations
1)      First generation computer
2)      Second generation computer
3)      Third generation computer
4)      Fourth generation computer

First Generation Computer:-(Period: 1940-1955)

            First generation computers were very large in size they use Vacuum tube, punched card and magnetic tapes. They occupies large place in large air-conditioned room.

Disadvantages:

  • Occupies large place
  • Produces large heat so requires Air-condition.
  • Speed is very low
  • Cost very expensive
  • Required High power
  • Access only by programmers

Second Generation Computer :-( Period: 1956-1963)

            Second generation computers were faster and smaller computer machines which uses transistors in place of vacuum tubes, they used programming languages like FORTRAN.

Advantages:
           
When compare to first generation computers second generation computers are very fast and small in size, they uses computer programming languages which are single operating systems.

Third Generation Computer :-( Period: 1964-1969)

            Third generation computers used Integrated circuits and these computer speed and storage capacity is very larger when compare to previous generation computer systems.

Advantages:

  • Very fast
  • Small in size
  • High storage capacity
  • Low cost

Fourth Generation Computer :-( Period: from 1970-till date)

            In early 1970’s fourth generation computers were introduced which uses Very Large Integrated chips (VLSI) technology chips.

Advantages:


  • Very fast
  • Small in size
  • High storage capacity
  • Low cost
  • Portable
  • Reliable
  • Low power consumption
  • Very easy to access.
Computer components:-

Computer is mainly divided into 2 components,

1)      Hard ware components: these are the physical components like computer peripherals example CPU, keyboard, mouse, monitor, printer, memory devices, circuits etc...

2)      Software components: these are the collection of programs which are used to run hard ware components example System software like operating system, Application software like MS Office, database software like DBMS etc…

Hardware components are the physical components which human being can see and touch .where as software components are the collection of programs which human being cannot see and touch. Software components are the programs which are used to run the hard ware components. 

Hardware components:

1)      Input devices: Input devices are used to give input to the system in form of data and instructions like alphabets, numbers, symbols, images etc…these are the physical components/Hard ware components which we can see and touch.

Example: Keyboard, Mouse, light pen, joystick, optical character reader, optical mark reader, CCD camera etc…

KEYBOARD: Programs and data are entered in to a computer through keyboard, it is similar to type writer it contains alphabets, numbers, special characters and some special control keys. When a key is pressed an electronic signal is produced which is detected by an electric circuit called keyboard encoder .it will send this signal to cpu and cpu process the signal and give out put on output device.
     
It contains different collection of keys like

standard typewriter keys which are in QWERTY  format of alphabets, numbers, control keys like space bar, shift, Tab and caps lock, Enter key etc…

Cursor movement keys like PgUp, PgDown, and uparrow, down arrow, left and right arrow, which are used to control the page on the screen.

Numeric keys like numbers from 0-9 and special keys like (+,-,*, /,).

Function keys it contains function keys from F1 to F12, each key have different functions according to the application.

 MOUSE: mouse is a small object that can roll on a hard surface which controls the movement of cursor on screen. There are different types of mouse

Mechanical Mouse: it has a rubber ball on its surface that can roll in all directions. Mechanical sensors within mouse detect the direction of ball and move the cursor on the screen in that direction.

Optical Mechanical: it is same as mechanical mouse but it uses optical sensors to detect the motion of ball.

Optical: it uses laser light to detect the mouse motion it not need rubber ball it gives response quickly but expensive.

 SCANNERS:

scanning device are Input devices which translates data/information in the form of Images and give to computer system.

OMR :
Special marks such as squares/bubbles are prepared on examination answer sheets with pencil or pen are detect by this OMR  and sends signals to the computer as input.

1)      Output devices: Output devices are physical components which are used to provide output to the user.
Example: Based on the output, the devices are divided into two types
  Monitor if the output is soft copy,
  Printer if the output is Hard copy.

MONITOR :
Monitors are the screens which are used to display the data on it. the data may be in any form like images, alphabets, numbers,special characters etc…there are many types of monitors based on the color,size,shape.

Monochrome monitors: Monochrome monitors actually display two colors, one for the background and another for foreground. The color is black and white.

Color Monitors: These monitors can display output in colors which supports 16 to 256 different colors.

CRT: cathode ray tube monitors are commonly used display screens which contains vacuum tube to display data on screen. It produces a light beam which reflects on the flat surface which coated with phosphorus material which produces picture on the screen. But it consumes more power and occupies more space.

Flat panel Display: This flat panel display is much thinner and is less in weight and consumes less power and thus they are more useful in portable computers.
LCD (Liquid Cristal Display) and LED (Electro Luminescent Display) are two technologies used in this flat panel display.

PRINTERS:
Printers are output devices which are used to give output in the form of hard copy in papers. We use different Printers in different applications.

Ink Jet printers:
 It uses dot matrix approach to print text and graphics. Earlier ink jet printers used one or more nozzles in print head that emit a steady stream of tiny ink drops. It uses Ink cartridges contain tiny heaters. The print quality is very neat, and speed is very low.

Drum printers:
 A drum printer uses a rapidly rotating drum which prints data in line format, first the drum heats and it dip in toner and then roll on the paper. It prints 200 to 2000 lines per minute, they are very fast in speed and cost is very less.

Laser Printer:

 This is a type of printer that utilizes a laser beam to produce an image on drum. The light of the laser alters the electrical charge on the drum wherever it hits. The drum is then rolled through toner, which is picked up by the charged portions of the drum. Finally, the toner is transferred to the paper through combination of heat and pressure. These are also very fast and les expensive.

Memory :
Memory is a place where data is stored in the form of bits. It is stored in computer system in binary form i.e. combination of 0‘s and 1’s.It is a Magnetic material which is used to store data.
Memory is a Hardware/Physical component of a computer system and it is a major part in central Processing Unit (CPU).
The Units of memory for measurements is Bytes
1 byte = 8 bits (combination of 0 and 1)
1 Kilo Byte = 1024 bytes (2^10)
1 Mega Byte = 1024 KB (2^20)
1 Giga Byte = 1024 MB (2^3) etc….
Memory in computer system is mainly divided in two types
1) Primary Memory and
2) Secondary Memory.
Primary Memory: Primary storage is main memory to store temporary data.
Example RAM, ROM, Cache Memory etc…
These are very small in size but they access data very fast. They are volatile because the data in primary memory will loss when power is off. 

RAM (Random Access Memory) : A RAM is computer main memory which is used to store data temporarily and it is a volatile memory it loses data when system is power off.
It is very fast to access the data, all the soft ware programs will first store in this ram memory from main memory (Hard disk) and then access by CPU whose speed is very high. Actually the accessing speed of Hard disk is very slow and CPU speed is very fast so, RAM memory act as mediator to transfer data from CPU to Memory and vice versa.

ROM (Read only memory) : A ROM memory is also a main memory which is used to store the primary soft ware data, this data is stored by computer manufacturers which contains the data of system. It store critical programs of system which boots the computer and also stores the software of input and output devices like keyboard software, monitor software etc…It is a non volatile memory which stores the data forever which cannot be changed or erased.

 Cache Memory: It is a very fast accessible memory even than RAM memory so it is sandwich between RAM and CPU. Its size very small but very fast and it is a volatile memory.

SECONDARY MEMORY: Secondary memory is a hardware component of computer system which is used to store data permanently and it can store very large amount of data. Compare to primary memory accessing speed is slow due to huge storing size and capacity. They use magnetic material to store data and they are non-volatile which store data even power of switch off.
Examples: Hard Disk, Floppy disk, Magnetic tapes, Compact Disk, Pen drives, Memory Cards etc…

Floppy Disks: Floppy disk is round pieces of flat plastic magnetic disk that store data. The sizes of floppy disks are 3 1/2 inches to 5 1/2 inches. Its store capacity is low up to Megabytes.

Hard Disk: It is a magnetic disk on which you can store computer data. It can store large amount of data compare to floppy disks i.e. from Kilo Bytes to Tera Byte. A single hard disk usually consists of several platters. Platter is a round magnetic plate that coated with magnetic material on both sides. And it requires two read and write arm which are used to store the data and to retrieve the data. Each platter is divided into several equal numbers of tracks; each track is again divided into sectors. All plates are connected with a rod called cylinder.

CD: Compact Disk are Read only Memory, i.e it can write only once and cannot write next time but read many times. It is an optical disk which stores large data. To read data from CD disk we need CD player/Drive. Its store size is up to 700 MB.


Magnetic Tape: Is is a magnetically coated strip of plastic on which data can be encoded. Tapes for computers are similar to tapes used to store music. This is the oldest storage media used till today. It needs a player to read these magnetic tapes and while reading and wriring data on it a arm is always contact to this tape so it will damage soon.