Friday, 29 December 2017

Winter break holiday homework

Winter break holiday homework
1. Write C++ Programs for the following questions.
i. Wap to enter a mXn matrix and find the smallest and greatest element of it.
ii. Wap to enter a mXn matrix and make all the elements above the diagonal blank.
iii. Wap to find the sum of n natural numbers starting from a given number by creating a function named fsumz(). The function will receive two integers s, n and print all numbers starting from s to n.
iv. Wap to enter 2 strings and compare them. The program should return 0 if the two strings are equal otherwise returns -1.
v. Wap to enter an array of 10 elements and swap the first and last element of it.
vi. Complete the program of ques no. 26 of page no 323 of chapter no. 11of sumita arora book.

2.  Find the output of the questions starting from the ques no. 11 to 16 of page no 322- 323 of chapter 11 of Sumita arora book.

Thursday, 14 December 2017

Good Morning Students... I am back after a long time... Try this program in your system and see the out put

//Delete the occurrence of a particular no from array and fill it by 0 and then rearrange them
#include<iostream.h>
//#include<stdlib.h>
#include<conio.h>
void main()
{
int a[40],b[40],s,i,j=0,f;
cout<<"\nEnter the total no. of elements in the array : ";
cin>>s;
cout<<"\nEnter the array elements\n";
    for(i=0;i<s;i++)
    {
        cout<<"\nElement no.:"<<i+1<<": ";
        cin>>a[i];
    }
cout<<"\nYou have entered the elements as : \n\n";
       for(i=0;i<s;i++)
    {
           cout<<a[i]<<" ";
    }
cout<<"\n\nEnter the element to be deleted from the array:  ";
cin>>f;
cout<<"\nAfter replacing "<<f<<" by 0 we get\n \n";
    for(i=0;i<s;i++)
    {
         if(a[i]==f) 
         {
          a[i]=0;
         }
    }
    for(i=0;i<s;i++)
    {
           cout<<a[i]<<" ";
    }
 
    for(i=0;i<s;i++)
    {
           if(a[i]==0)
           {
             b[j]=a[i];
             j++;
           }
    }
       for(i=0;i<s;i++)
    {
           if(a[i]!=0)
           {
             b[j]=a[i];
             j++;
           }
    }
cout<<"\n\nAfter rearranging elements we get\n\n";
      for(i=0;i<s;i++)
    {
           cout<<b[i]<<" ";
    }
   
 getch();     
}

Delete the occurrence of a particular no from array and fill it by null

//Delete the occurrence of a particular no from array and fill it by null
#include<iostream.h>
//#include<stdlib.h>
#include<conio.h>
void main()
{
int a[40],s,i,f;
cout<<"Enter the total no. of elements in the array";
cin>>s;
cout<<"Enter the array elements";
    for(i=0;i<s;i++)
    {
        cout<<"Element no.:"<<i+1<<": ";
        cin>>a[i];
    }
cout<<"Enter the element to be deleted from the array: ";
cin>>f;
    for(i=0;i<s;i++)
    {
         if(a[i]==f)
         {
         (char)a[i]=(char)32;
         }
    }
    for(i=0;i<s;i++)
    {
        if(a[i]==(char)32)
        {
           cout<<(char)a[i]<<" ";
        }
        else
        {
           cout<<a[i]<<" ";
        }
    }
 getch();     
}

Saturday, 14 October 2017

Practical-8

PRACTICAL- 8
Aim of the practical:-
Write a program (WAP) to enter any number and check that whether it is a Prime number or Composite number.

Header files used:-
#include <iostream.h>
#include <stdlib.h>
Conditional statements/Loops used:-
i.                   If– else statement
ii.                 while loop/for loop
Prime  & Composite Number:
A prime number is a natural number greater than 1 which has no positive divisors other than 1 and itself.
A natural number that is greater than 1 and that is not a prime number is called a Composite number.
Procedures followed:-
The user will be asked to enter any number. The number entered by the user will be divided with all numbers starting from 1 up to the number itself to find its divisors, using a for loop and an if statement. By comparing the number of divisors found with 2 using an if-else statement we can find weather it is a prime or composite number.

Coding:-

Practical-7

PRACTICAL- 7
Aim of the practical:-
Write a program (WAP) to enter any number and check that whether it is an Armstrong number or not.

Header files used:-
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
Conditional statements/Loops used:-
i.                   If– else statement
ii.                 while loop
Armstrong Number:-
A positive number is called an Armstrong number if the number formed by the sum of the cubes of indevidual digits of that number is the number itself.
For example:- 0,1,153,370,371 and 407
153=1*1*1+5*5*5+3*3*3
Procedures followed:-
The user will be asked to enter any number. We need to store a duplicate copy of that number in another variable. Then the each digit of the number will be added after finding its cube and stored in another variable. After this the number formed will be compared with the duplicate copy stored earlier to check whether it is an Armstrong number or not.

Coding:-

Tuesday, 10 October 2017

Practical - 6

          PRACTICAL- 6
Aim of the practical:-
Write a program (WAP) to enter any number and check that whether it is palindrome or not.

Header files used:-
#include <iostream.h>
#include <stdlib.h>
Conditional statements/Loops used:-
i.                    If– else statement
ii.                  while loop
Procedures followed:-
The user will be asked to enter any number. We need to store a duplicate copy of that number in another variable. Then the reverse of that number will be formed using a while loop. After forming the reverse of the number it will be compared with the duplicate copy stored earlier to check whether it is palindrome or not.
Coding:-

Practical-5

PRACTICAL- 5
Aim of the practical:-
Write a program (WAP) to enter the value of Coefficient of x2 (a), Coefficient of x (b) and constant term (c), and  find the roots of a quadratic equation ax2+bx+c=0
Header files used:-
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
Conditional statements/Loops used:-
i.                   If– else –if ladder
Procedures followed:-
The coefficient of x2, x, and constant term of the quadratic equation ax2 + bx + c = 0 is entered by the user. Then we find the discriminant by applying the formula D=b2 - 4ac.
Then this discriminant is compared with 0 in an if- else- if ladder and the roots are found as per the rules given below.
i.                  D>0, Roots are real and distinct.
ii.                D=0, Roots are real and equal.
iii.              D<0, Roots are imaginary.

Coding:-


Monday, 2 October 2017

Practical-4

PRACTICAL-4
Aim of the practical:-
Write a program (WAP) to check the input from keyboard is a alphabet or number or a special character.
Header files used:-
#include <iostream.h>
#include <stdlib.h>
Conditional statements/Loops used:-
i.                   If– else –if ladder
Procedures followed:-
The user will be asked to press any key from the keyboard. Then the input will be compared with its range of ASCII values in successive if- else if () statements to identify which particular category it belongs to (alphabets/numbers/special characters).And finally the condition which it will satisfy will be shown as the output.
The details of range of ASCII values are:-
Characters
ASCII values
A… Z (Upper case alphabets)
65 to 90
a… z  (Lower case alphabets)
97 to 122
0…9   (Numbers)
48 to 57

Coding:-

Dussehra Puja Holiday Home Work

1.  Evaluate the following expressions
a.  x – y < z  &&  y + z > x || x-z <= y – x + z
i.            If x=4,y=7 and z=10
ii.          If x=3, y=8 and z=-5
iii.         If x=-5, y=1 and z=3
b.  (y) && (y-z) || !(2y+z-x)
i.            If x=13,y=14 and z=5
ii.          If x=10, y=5 and z=5
iii.         If x=5,y=6 and z=9
2.  Determine the values of the following C++ expressions when a, b, c are integers and d, f are floating point numbers. The values of a=5,b=3 and d=1.5
i.            f= a + b/a
ii.          c= d * a + b
iii.         c= (a++)  *d +a
iv.        f= (++b)*b – a
v.          c= a - (b++)*(- - a)
3.  Suppose a, b, c are integers and a=3, b=6, c=-5 and x, y, z are floating point variables where x=8.8, y=3.5, z=-5.2
Determine the value of the following expressions.
i.            a % c
ii.          a*b/c
iii.         (a*c)%b
iv.        x/y
v.          x/(x + y)
vi.        int (x) % int (y)
4.  Wap to input a number. If the number is even then print its square otherwise print its cube. (do it using conditional operator)
5.  Wap to input a number. If the number is even and positive then print its square root otherwise print its cube.
6.  Wap to enter any two numbers from the user other then zero and also any arithmetic operator (+, - , *, /). Then it should produce the arithmetic operation between the two numbers and finally displays the result.
7.  Wap to enter any year from the keyboard and display weather it is a leap year or non- leap year..
8.  Find the output of the question numbers 11 and 12 of chapter no.10 page no.266 and 267 of Sumita Arora book .


Practical-3

PRACTICAL-3
Aim of the practical:-
Write a program (WAP) to enter any three different numbers and arrange them in both ascending and descending order.
Header files used:-
#include <iostream.h>
#include <stdlib.h>
Conditional statements/Loops used:-
i.                   If statement
ii.                 If else statement
Procedures followed:-
The user will be asked to enter any three different numbers. One of the three numbers will be taken as the greatest and will be compared with the other two in successive if () statements to find out the greatest among the all.
After finding the greatest of all, the other two will be compared in successive if else statements to find the 2nd and 3rd greatest of them.

Coding:-

Monday, 25 September 2017

Extra Class Time Table

All students of Class –XI are here by informed to attend the extra classes to be conducted in school premises for 3 days in Mathematics and Computer Science.The details of classes to be conducted are as follows.


DATE/ TIME

           8.00 AM    TO    10.00 AM

        10.00 AM      TO    12.00 NOON

26.09.2017

COMPUTER SCIENCE

 

27.09.2017

COMPUTER SCIENCE

MATHEMATICS

28.09.2017

COMPUTER SCIENCE

MATHEMATICS

Friday, 22 September 2017

PRACTICAL-2

PRACTICAL-2
Aim of the practical:-
Write a program (WAP) to calculate volume of a cone, sphere and cylinder.

Header files used:-
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
Formulas used:-
i.                Volume of a circular cone = (1/3)πr2h.
ii.              Volume of a cylinder = πr2h
iii.           Volume of a sphere = (4/3)πr3
Procedures followed:-
The user will be asked to enter the radius or radius and height in successive instances in the program using different cout statements. Different formulas will be used to find the volume of cone, cylinder and sphere respectively. While using the formula the function pow() will be used to find the square or cube of any value. The header file math.h will also be used which contains the definition of pow() function.

Coding:-

Friday, 25 August 2017

Memory Concept



Memory Units:-Ø  A bit is the smallest storage unit of memory.
Ø  A nibble is a collection of 4 bits.
Ø  Eight bits combined together to form a single byte, which in turn represents a single character. Other units of memory are as follows
  


8bits
=
1Byte
1024 bytes
=
1 Kilo Byte (KB)
1024 KB
=
1 Mega Byte (MB)
1024 MB
=
1 Giga Byte (GB)
1024 GB
=
1 Terra Byte (TB)
1024 TB
=
1 Peta Byte (PB)
1024 PB
=
1 Exa Byte (EB)
1024 EB
=
1 Zetta Byte (ZB)
1024 ZB
=
1 Yotta Byte (YB)
The computer memories can be divided into following categories:
Primary Memory
Secondary memory
Cache Memory
Primary Memory
Ø Primary memory or main memory is a Metal Oxide Semiconductor (MOS) memory used for storing program and data during the execution of the program.
Ø It is directly accessible to CPU.
Ø Broadly primary memory can be of two types – RAM (Random Access Memory) and ROM (Read only memory).
Random Access Memory (RAM)
Ø In case of RAM, the memory can be accessed from any desired location randomly.
Ø The instructions and data that we input into the computer are stored in
the RAM of the Computer.
Ø It is a read/write memory, so data can be both read from and written to the RAM.
Ø It is a volatile memory and loses its contents when the power is switched off or interrupted.
Ø Nowadays RAMs are available in gigabytes.
Ø The normal memory access time of a RAM is 20-80 ns.
Ø RAM can be broadly classified into two categories:
I.           Dynamic RAM (DRAM)
II.          Static RAM (SRAM).


SRAM
DRAM
It is faster in operation
It is slower in operation
It don’t require refresh cycles
It require refresh cycles
It is a memory cell contains 6 transistors
Its memory cell contains 1 transistor and 1 capacitor
Its cost per memory is very high
Its cost per memory is less.
It is not commonly being used as it is expensive
It is commonly used everywhere as it is less expensive
Used in cache memory of processors
It is used in computers, smart phones, tablets as normal RAM



ROM (Read Only Memory):-
Ø The special device where computer start-up instructions are stored is called ROM
Ø It is non-volatile in nature, i.e., its contents are not lost after power is switched off.
Ø Data stored in it are can be read and cannot be altered by any one.
Ø ROM chips are not only used in computers but also in electronic devices like Washing machines, Microwave oven etc.
Ø Once a ROM chip is being programmed it can’t be changed. If it is to be corrected then we have to replace it with a new one.
Programmable  Read  Only  Memory  (PROM):  
This  type  of  ROM  can  be programmed  even  after  its manufacture using  a PROM programmer  circuit. But once a PROM is programmed, it becomes just like ROM i.e. it cannot be changed.
Erasable Programmable Read Only Memory (EPROM): In this type of ROM, the contents can be erased and the memory can be reprogrammed. To erase the data, an EPROM is exposed to ultraviolet light and then it can be reprogrammed using a PROM programmer circuit. When  the  EPROM  is  in  use,  then  it  behaves  like  a ROM, that means the information can only be read.
Electrically Erasable Programmable Read Only Memory (EEPROM):  The contents of this type of ROM can be erased and then reprogrammed using electric signals. This makes it an excellent back up for RAM whose contents are lost when the power is switched off. When the power is returned, the contents of EEPROM are copied back into  the RAM and  the computer continues working without any data loss. Nowadays RAMs and EEPROMs are integrated in a single chip.
Cache Memory
Ø Cache memory is a special high speed memory made up of high speed static RAMs.
Ø It is used to hold frequently accessed data and instructions.
Ø It is placed between the CPU and the main memory. Whenever some data is required, the CPU first looks into cache. 
Ø If data  is  found, we call  it a  cache hit and  the  information  is  transferred  to  the CPU. 
Ø In case of a miss, the main memory is accessed.
Ø  So access of frequently used data becomes very fast with cache memory.
Ø There  are  two types of cache memory:
i.            L1 cache
ii.          L2 cache
L1 Cache
L2 Cache
Its memory capacity is low.
Its memory capacity is high.
It is present inside CPU.
It is soldered on mother board.
It is implemented using SRAM.
It is implemented using DRAM.
It is assessed first for any data.
It is accessed if data is not found in L1 Cache.
It can be accessed faster.
Its access time is slower.





Secondary Storage Media
There are the following main types of storage media.
(a)              Magnetic    
(b)              Optical     
(c)               Solid State
Magnetic  storage media: Examples of magnetic  storage media  are hard disks,  floppy disks and magnetic tapes. Magnetic media is coated with a magnetic sensitive layer and this  layer  is  magnetized  in  clockwise  or  anticlockwise  directions,  which  then  are interpreted as binary 1s and 0s at reading.
Floppy  Disk  (Diskette):  A  floppy  disk  is  a  flexible  disk made  up  of  Mylar  with  a magnetic coating on  it.
Ø  It is packaged inside a protective plastic envelope.
Ø These were one of the oldest type of portable storage devices that could store up to 1.44 MB of data but now they are no longer in use. 
Hard disk: A hard disk consists of one or more circular disks called platters which are mounted on a common spindle. 
Ø Each surface of a platter is coated with a magnetic material. 
Ø Both  surfaces  of  each  disk  are  capable  of  storing  data  except  the  top  and bottom disk where only  the  inner  surface  is used.
Ø The information is  recorded on  the surface of the rotating disk by magnetic read/write heads.
Ø These heads are joined to a common arm known as access arm.
Ø This arm moves over the surface of the rotating disk
Ø Information  is  recorded on each of  these disks  in  the  form of  concentric  circles  called tracks  which  are  further  divided  into  sectors. 
Ø Hard  drives  however,  are  not  very portable  and  are  primarily  used  internally  in  a  computer  system. 
Ø Today the hard disks have the storage capacity of several gigabytes to terabytes.
Optical storage media
On an optical storage media information is stored and read using a laser beam.
Ø The data is stored as a spiral pattern of pits and ridges denoting binary 0 and binary 1.  
Ø Examples of optical media are CDs, DVDs etc.
Compact Disk: A compact disk or CD  can  store approximately 650  to 700 megabytes (MB) of data.
Ø To read the data, an infrared laser is beamed through the CD's polycarbonate substrate.
There are three types of CDs:
CD- ROM:  It stands for Compact Disk  - Read Only Memory  and  data  is written  on these disks at the time of manufacture.
Ø Data cannot be changed but can only be read by a laser beam in the form of a continuous spiral.
Ø These are used for text, audio and video distribution like games, encyclopedias and application softwares.
CD-R: It stands for Compact Disk- Recordable. Data can be recorded on these disks but only once.
Ø So we can write data on these disks through a read/write CD drive but after that the disk cannot be erased /modified.
CD-RW:  It stands for Compact Disk-Rewritable. 
Ø It can be read or written multiple times.
DVD:  It stands  for Digital Versatile Disk or Digital Video Disk.
Ø A DVD holds 4.7 GB to 17 GB of data.
Ø  Like CDs DVDs also come in three varieties
a.   DVD- ROM 
b.   DVD- R
c.    DVD-RW
Blue Ray Disk: This is the latest optical storage media to store high definition audio and video.
Ø It looks like a CD or DVD but can store up to 27 GB of data on a single layer disk and up to 54 GB of data on a dual layer disk.
Ø Where CDs or DVDs use red laser beam, the blue ray disk uses a blue laser to read/write data on a disk. 
Ø As the wavelength of the blue ray is shorter, more data per unit area can be stored on the disk.
Ø This is because due to shorter wavelength, it is possible to focus the laser spot with greater precision. Hence data can be packed more tightly.
Ø Blue-ray Disc (BD) was developed  to enable  recording,  rewriting and playback of high-definition video  (HD), as well as storing large amounts of data.
Solid State Memories
Ø The term ‘solid-state’  essentially means  ‘no moving  parts’.
Ø These devices  store  data  using  a special type of memory called flash memory.
Ø SSD, Solid-state drive (or flash memory) is used mainly in digital cameras, pen drives or USB flash drives.

Pen  Drives:  Pen  Drives  or  Thumb  drives  or  Flash  drives  are  the  recently  emerged portable storage media.
Ø It is an EEPROM based flash memory which can be repeatedly erased and written using electric signals.
Ø This memory is coupled with a USB connector through which it can be plugged into the computer.
Ø They have a capacity of 8gb/16gb/32gb etc.
PORTS
A port is an interface between the motherboard and an external device. Different types of port are available on motherboard as serial port, parallel port, PS/2 port, USB port, SCSI port etc.
Serial port (COM Port): A serial port transmits data one bit at a time. Typically on older PCs, a modem, mouse, or keyboard would be connected via serial ports. Serial cables are cheaper to make than parallel cables and easier to shield from interference. It is also called communication port.
Parallel  Port:  It  supports  parallel  communication  i.e. it can  send  several  bits simultaneously. 
Ø can  send  8  bits  (1  byte)  at  a  time  simultaneously  (in  parallel). Hence data transmission is faster through these ports.
Ø Parallel ports are used to connect printers, scanners, CD writers etc.
USB (Universal Serial Bus): It is a newer type of serial connection that is much faster than the old serial ports.
Ø USB is also much smarter and more versatile since it allows the "daisy chaining" of up to 127 USB peripherals connected to one port. It provides plug & play communication.
PS/2 Port: PS/2 ports are special ports for connecting the keyboard and mouse to some PC systems. This type of port was invented by IBM
FireWire Port: The FireWire port has the ability to interact with a number of different devices since it provides a single plug and socket connection for all devices.
Ø A FireWire port can provide an ideal way to connect a  scanner  and digital  camera/camcorder  to a  computer  system  as  the data  transfer  is relatively faster than on USB and also results in excellent quality.
Infrared Port: An IR port is a port which sends and receives infrared signals from other devices. It is a wireless type port with a limited range of 5-10ft. 
Bluetooth: Bluetooth  uses  short-range  radio  frequencies  to  transmit  information  from  fixed  and mobile devices.
Ø These devices must be within the range of 32 feet, or 10 meters for Bluetooth to effectively work.
Ø  A  Bluetooth port enables connections for Bluetooth-enabled devices for synchronizing.
Ø The  devices  that  are  Bluetooth  enabled  contain  a  small  transceiver  chip that  allows  them  to  communicate with  other  Bluetooth  enabled  computer  or  device.
Ø Data can be exchanged at the rate of about 2 megabit per second.


EXCERCISE
a)  Define word length of a microprocessor.
b)  Name the two types of Primary Memory. 
c)  What is the purpose of System Clock?
d)  Differentiate between CISC and RISC processors.
e)  Why do we use secondary storage? Name any two secondary storage devices.
f)  How is Computer’s internal memory important?
g)  Why is it more appropriate to call RAM as Read-Write memory?
h)  What is the purpose of Cache memory?
i)  Explain in brief the different ports and their purposes.
j)    Distinguish between the following pairs:
a.  Primary memory and Secondary memory    
c.   RAM and ROM
d.  Bluetooth and Infrared port