calculator


#include<iostream>
using namespace std;
int main() 
int a,b,s,op;  ; 
cout<<"\t\t\t\tCALCULATOR\n\t\t\tAll Rights Reserved\a\n"; 
cout<<"\t\tIllegal Copying is punishable and u would be sent as a prisoner";
cout<<"\t\t\t to kendriya vidyalaya no 1 naval base\a\nEnter Number A\a :"; 
cin>>a; 
cout<<"\nEnter Number B\a :"; 
cin>>b; 
cout<<endl<<"\t\t1.Addition\n\t\t2.Subtraction\n\t\t"; 
cout<<"3.Division(Whole Numbers only)\n\t\t4.Multiplication\n\t\t"; 
cout<<"5.Square of A\n\t\t6.Square of B\n\t\t"; 
cout<<"7.'A'square - 'B'square\n\t\t8.'A'square + 'B'square\n\t\t"; 
cout<<"9.'A'square * 'B'square\n\t\t10.'A'square / 'B'square(whole numbers only"; 
cout<<"\n\t\t11.'A'cube\n\t\t12.'B'cube"; 
cout<<endl<<" Enter Choice\a :"; 
cin>>op; 
switch(op) 
case 1:s=a+b; 
     cout<<"Sum = \a"<<s; 
     break; 
case 2:s=a-b; 
     cout<<"Difference =\a "<<s; 
     break; 
     case 3:s=a/b; 
     cout<<"Quotient =\a "<<s; 
     break; 
case 4:s=a*b; 
     cout<<"Product =\a "<<s; 
     break; 
case 5:s=a*a; 
     cout<<"Square =\a "<<s; 
     break; 
case 6:s=b*b; 
     cout<<"Square =\a "<<s; 
     break; 
case 7:s=(a*a)-(b*b); 
     cout<<"Answer =\a "<<s; 
     break; 
case 8:s=(a*a)+(b*b); 
     cout<<"Answer =\a "<<s; 
     break; 
case 9:s=(a*a)*(b*b); 
     cout<<"Answer =\a "<<s; 
     break; 
case 10:s=(a*a)/(b*b); 
     cout<<"Answer =\a "<<s; 
     break; 
case 11:s=a*a*a; 
     cout<<"Answer =\a "<<s; 
     break; 
case 12:s=b*b*b; 
     cout<<"Answer =\a "<<s; 
     break; 
default:cout<<"Invalid\a Choice\a"; 
return 0; 
}                        

 output





  • temperature conversion


#include<iostream>

using namespace std;
int main()
{
int choice,covtemp,temp;
cout<<"themprature conversion menu\n";
cout<<"1.fahrenheit to celsius\n";
cout<<"2.celsius to farenheit\n";
cout<<"enter ur choice:\n\a";
cin>>choice;
switch(choice)
{
case 1:
cout<<" enter the temp in fahrenheit\n";
cin>>temp;
covtemp=(temp-32)/1.8;
cout<<"the temp in celsius is"<<covtemp;
          break;
 case 2:
  cout<<"enter the temp in celsius\n";
   cin>>temp;
   covtemp=(temp-1.8)/32;
   cout<<" themp in fahrenheit is"<<covtemp;
   break;
   } 
   return 0;
}
  
  • to check whether the character is a vowel

#include<iostream>
using namespace std;
int main()
{
char a;
int v=0;
cout<<" enter a character\a\n";
cin>>a;
switch(tolower(a))
{
case 'a':
          case 'e':
          case 'i':
          case 'o':
          case 'u':
          v++;break;
}
if(v>0)
cout<<"itz a vowel";
else
cout<<" itz not a vowel";
return 0;
}



0 comments:

Post a Comment