Tuesday, 3 September 2013

SWITCH STATEMENT

SWITCH CASE:

SYNTAX:

switch(expression)
{
case 1: statement 1;
             break;
case 2: statement 2;
            break;
case 3: statement 3;
             break;
default : statement 4;
               break;
}

SAMPLE PROGRAM :

#include<iostream.h>
#include<conio.h>
void main()
{
int ch;
cout <<"\n ENTER THE NUMBERS BELOW FIVE ";
cin >> ch;
switch(ch)
{
case 1:cout <<"\n THE NO. IS ONE ";
           break;
case 2: cout <<"\n THE NO. IS TWO ";
            break;
case 3: cout <<"\n THE NO. IS THREE ";
            break;
case 4: cout <<"\n THE NO. IS FOUR ";
            break;
default : cout <<"\n ENTER THE CORRECT CHOICE ";
              break;
}
getch();
}

 


Monday, 2 September 2013

CONSTRUCTOR WITH ARGUMENTS

CONSTRUCTOR WITH ARGUMENTS:

#include<conio.h>
class add
{
int num1, num2, sum=0;
public()
{
add( int a, int b)       \\ CONSTRUCTOR WITH ARGUMENTS \\
{
   num1=a;
   num2=b;
}
void addition()
{
sum=num1+num2;
}
void display()
{
cout <<"\n NUM1= " <<num1;
cout <<"\n NUM2= " <<num2;
cout <<"\n SUM = " <<sum;
}
};
void main()
{
clrscr();
add a(50, 60) ;
a.addition();
a.display();
getch();
}

C++ statements with syntax

If statement : 

Syntax :   

if(test condition)
{
   statment1;
}

Example:

#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
int age;
cout <<"\n Enter the age";
cin >>age;
if (age>=18)
{
    cout <<"\n YOU CAN VOTE ";
}
getch();
}

Explanation : 

                 The control enters the if statement and the test condition will checked and if the condition is TRUE  then the output will be displayed . If the condition is FALSE then nothing will be displayed.


If......else Statement :

Syntax:

if(test condition) 

statement 1;

else 

statement 2;

Example :

#include<iostream.h>
#include<conio.h>
void main()
{
int n;
cout <<"\n Enter the number";
cin >>n;
if (n%2==0)
cout <<"\n You have entered EVEN no";
else
cout <<"\n You have entered ODD no ";
getch();
}

Explanation :

                 The control enters the main() function . After getting the input value the test condition will checked and if the test condition is TRUE then the statement 1 will be displayed,  otherwise statement 2 will be displayed .






 


            

Saturday, 31 August 2013

INTRODUCTION TO COMPUTERS

Evaluations of Computers

                                     The word computer comes from the "compute" which means to calculate. So a computer is normally considered to be a calculating device that can perform Arithmetic operations at enormous speed. More accurately ,a computer may be defined as a device that operates upon information or data .A computer can store, process and retive data as and when desired.  The fact that computers process data is so fundamental that many people have started calling it a Data processor.

CHARLES BABBAGE is considered as the "FATHER OF THE COMPUTER". During his period , mathematical and statical tables were prepared by group of clerks . Babbage had to spend several hours for checking the tables . In the result Babbage designed a "DIFFERENCE ENGINE " in the year 1822 which could produce reliable tablets . In 1842 , Babbage came out with an idea of "Analytical Engine " that was intended to be fully automatic . His efforts established a number of principles which have been shown to be fundamental to the design of any Digital Computers.