Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Thursday, 18 July 2013



#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "iostream"

using namespace std;

void AsciiValue();
void Character();
void LowerToUpper();
void UpperToLower();

int _tmain(int argc, _TCHAR* argv[])
{
       int choice;
       char option;
       do
       {
              cout<<"press 1 to convert ascii value to character"<<endl;
              cout<<"press 2 to convert character to ascii value"<<endl;
              cout<<"press 3 to conver alphabet from lower to upper case"<<endl;
              cout<<"press 4 to conver alphabet from upper to lower case"<<endl;
              cout<<"press 5 for exit"<<endl;
              cout<<"enter your choice"<<endl;
              cin>>choice;
              switch(choice)
              {
              case 1:
                     AsciiValue();
                     break;
              case 2:
                     Character();
                     break;
              case 3:
                     LowerToUpper();
                     break;
              case 4:
                     UpperToLower();
                     break;
              case 5:
                     exit(0);
              default:
                     cout<<"nothing match";
              }
              cout<<"would u like to continue?";
              cin>>option;
       }while(option=='y'||option=='Y');
              getch();
}
void AsciiValue()
{
       char ch;
       int a;
       cout<<"enter a character"<<endl;
       cin>>ch;
       a=ch;
       cout<<a<<endl;
}
void Character()
{
       int a;
       cout<<"enter a number"<<endl;
       cin>>a;
       cout<<(char)a<<endl;
}
void LowerToUpper()
{
       char ch;
       int a;
       cout<<"enter a character in lower case";
       cin>>ch;
       a=ch-32;
       cout<<(char)a;
       getch();
}
void UpperToLower()
{
       char ch;
       int a;
       cout<<"enter a character in upper case";
       cin>>ch;
       a=ch+32;
       cout<<(char)a;

       getch();}

#include "stdafx.h"
#include "conio.h"
#include "iostream"
#include "stdio.h"

using namespace std;

void AddNumber();
void AddIntegerNumer();
void AddRealNumber();
void AddCharNumber();
void SubtractNumber();
void MultiplyNumber();
void DivideNumber();
void ModulusNumber();


int _tmain(int argc, _TCHAR* argv[])
{
       char choice;
       char option;

       do
       {
              cout<<"press + to add two numbers"<<endl;
              cout<<"press - to subtract two numbers"<<endl;
              cout<<"press * to multiply two numbers"<<endl;
              cout<<"press / to divide two numbers"<<endl;
              cout<<"press % to take modulus of two numbers"<<endl;
              cout<<"press # for exit"<<endl;
              cout<<"enter your choice"<<endl;
              cin>>choice;

              switch(choice)
              {
              case '+':
                           {
                           int choice;
                           do
                           {
                                  cout<<"press 1 for integer nubmer addition"<<endl;
                    cout<<"press 2 for real number addition"<<endl;
                                  cout<<"press 3 for char number addition"<<endl;
                                  cout<<"press 4 for exit"<<endl;
                                  cout<<"enter your choice"<<endl;
                                  cin>>choice;

                                  switch(choice)
                                  {
                                  case 1:
                                         AddIntegerNumer();
                                         break;
                                  case 2:
                                         AddRealNumber();
                                         break;
                                  case 3:
                                         AddCharNumber();
                                         break;
                                  case 4:
                                         exit(0);
                                  default:
                                         cout<<"nothing match"<<endl;

                                  }
                                  cout<<"would you like to continue? press y or Y";
                                  cin>>option;
              }while(option=='y'||option=='Y');
                                 
                     }
                     break;
              case '-':
                     SubtractNumber();
                     break;
              case '*':
                     MultiplyNumber();
                     break;
              case '/':
                     DivideNumber();
                     break;
              case '%':
                     ModulusNumber();
                     break;
              case '#':
                     exit(0);
              default:
                     cout<<"nothing match"<<endl;
              }

                     cout<<"would you like to continue? press y or Y";
                     cin>>option;
              }while(option=='y'||option=='Y');
      
       getch();

}

void AddIntegerNumer()
{
       int n1,n2;
       int sum=0;
       cout<<"enter n1 and n2"<<endl;
       cin>>n1>>n2;
       sum=n1+n2;
       cout<<"sum="<<sum<<endl;
}

void AddRealNumber()
{
       int n1,n2;
       int sum=0;
       cout<<"enter n1 and n2"<<endl;
       cin>>n1>>n2;
       sum=n1+n2;
       cout<<"sum="<<sum<<endl;
}

void AddCharNumber()
{
       char ch1,ch2;
       int sum=0;
       cout<<"enter ch1 and ch2"<<endl;
       cin>>ch1>>ch2;
       sum=ch1+ch2;
       cout<<"sum="<<sum<<endl;
}

void SubtractNumber()

{
       int n1,n2;
       int subtract=0;
       cout<<"enter n1 and n2"<<endl;
       cin>>n1>>n2;
       subtract=n1-n2;
       cout<<"subtract="<<subtract<<endl;
}

void MultiplyNumber()
{
       int n1,n2;
       int multiply;
       cout<<"enter n1 and n2"<<endl;
       cin>>n1>>n2;
       multiply=n1*n2;
       cout<<"multiply="<<multiply<<endl;
}
void DivideNumber()
{
       int n1,n2;
       int division;
       cout<<"enter n1 and n2"<<endl;
       cin>>n1>>n2;
       division=n1/n2;
       cout<<"division="<<division<<endl;
}

void ModulusNumber()
{
       int n1,n2;
       int modulus;
       cout<<"enter n1 and n2"<<endl;
       cin>>n1>>n2;
       modulus=n1/n2;
       cout<<"modulus="<<modulus<<endl;

}


#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "iostream"

using namespace std;

void Area_1();
void Area_2();
void Area_3();

int _tmain(int argc, _TCHAR* argv[])
{
        Area_1();
        Area_2();
        Area_3();
        getch();
}

void Area_1()
{
       float a,r,p;                  ////// a is area , r is radius and p is pi ( 3.14 )
       p=3.14;
       cout<<"enter radius1"<<endl;
       cin>>r;
       a=p*r*r;
       cout<<"a1="<<a<<endl;
}
void Area_2()
{
       float a,r,p;
       p=3.14;
       cout<<"enter radius2"<<endl;
       cin>>r;
       a=p*r*r;
       cout<<"a2="<<a<<endl;
}
void Area_3()
{
       float a,r,p;
       p=3.14;
       cout<<"enter radius3"<<endl;
       cin>>r;
       a=p*r*r;
       cout<<"a3="<<a<<endl;

}


#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "iostream"

using namespace std;

void Number_1();
void Number_2();
void Number_3();
void Number_4();
void Number_5();

int _tmain(int argc, _TCHAR* argv[])
{
Number_1();
Number_2();
Number_3();
Number_4();
Number_5();
getch();

}
void Number_1()
{
int a;
float b;
cout<<"enter number1 in float"<<endl;
cin>>b;
a=b;
cout<<"a1="<<a<<endl;
}
void Number_2()
{
int a;
float b;
cout<<"enter numbe2 in float"<<endl;
cin>>b;
a=b;
cout<<"a2="<<a<<endl;
}
void Number_3()
{
int a;
float b;
cout<<"enter number3 in float"<<endl;
cin>>b;
a=b;
cout<<"a3="<<a<<endl;
}
void Number_4()
{
int a;
float b;
cout<<"enter number4 in float"<<endl;
cin>>b;
a=b;
cout<<"a4="<<a<<endl;
}
void Number_5()
{
int a;
float b;
cout<<"enter number5 in float"<<endl;
cin>>b;
a=b;
cout<<"a5="<<a<<endl;
}



#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "iostream"

using namespace std;

void Temperature_1();
void Temperature_2();
void Temperature_3();
void Temperature_4();
void Temperature_5();

int _tmain(int argc, _TCHAR* argv[])
{
        Temperature_1();
        Temperature_2();
        Temperature_3();
        Temperature_4();
        Temperature_5();
        getch();
}
void Temperature_1()
{
       float c,f;
       cout<<"enter temperature in celsius1"<<endl;
       cin>>c;
       f=(9/5)*c+32;
       cout<<"f1="<<f<<endl;
}
void Temperature_2()
{
       float c,f;
       cout<<"enter temperature in celsius2"<<endl;
       cin>>c;
       f=(9/5)*c+32;
       cout<<"f2="<<f<<endl;
}
void Temperature_3()
{
       float c,f;
       cout<<"enter temperature in celsius3"<<endl;
       cin>>c;
       f=(9/5)*c+32;
       cout<<"f3="<<f<<endl;
}
void Temperature_4()
{
       float c,f;
       cout<<"enter temperature in celsius4"<<endl;
       cin>>c;
       f=(9/5)*c+32;
       cout<<"f4="<<f<<endl;
}
void Temperature_5()
{
       float c,f;
       cout<<"enter temperature in celsius5"<<endl;
       cin>>c;
       f=(9/5)*c+32;
       cout<<"f5="<<f<<endl;

}