XII CS Project Format
XII CS Project Format
S.No.
Contents
Page No.
Science
Project File
Scientific Calculator
1. Certificate
2. Acknowledgement
3. Source Code
4. Virtual Tour
5. Bibliography
37
3
47
Principal
#include<iostream.h>
#include<process.h>
#include<stdio.h>
#include<conio.h>
#include<iomanip.h>
#include<math.h>
#include<stdlib.h>
#define PI 3.14159265
int *A, *B, *C, i, j, m, n, p, q, ip, ch, n1, n2, num, power, S, P, sign=1;
char choice='y', choice1='y', choice2='y';
float a, b, c, a1, a2, b1, b2, r_a, r_b, arg;
double result, fractpart, intpart, numf, x;
unsigned long BIN, OCT, DEC, HEX;
{
BIN=NUM;
int i=0, a[20];
while(NUM!=0)
{
a[i]=NUM%1000;
NUM=NUM/1000;
if(a[i]>111)
{
cout<<"\n\t Entered Number is not BINARY";
return;
}
i++;
}
i--;
cout<<"\n\t Octal equivalent of "<<BIN<<" (Binary) is ";
for( ;i>=0; i--)
{
switch(a[i])
{
case 0:
cout<<"0";
break;
case 1:
cout<<"1";
break;
case 10:
cout<<"2";
break;
case 11:
cout<<"3";
break;
case 100:
cout<<"4";
break;
case 101:
case 110:
case 111:
default:
cout<<"5";
break;
cout<<"6";
break;
cout<<"7";
break;
cout<<"\n\t Entered Number is not BINARY";
return;
}
}
}
{
BIN=NUM;
int b=0, a[6], i=0;
while(NUM!=0)
{
a[i]=NUM%10;
NUM=NUM/10;
if(a[i]!=1 && a[i]!=0)
{
cout<<"\n\t Entered Number is not BINARY";
return;
}
i++;
}
a[i]=2;
NUM=1;
for(i=0;a[i]!=2;i++)
{
b=b+a[i]*NUM;
NUM=NUM*2;
}
cout<<"\n\tDecimal equivalent of "<<BIN<<" (Binary) is "<<b;
}
{
BIN=NUM;
int i=0, a[5];
while(NUM!=0)
{
a[i]=NUM%10000;
NUM=NUM/10000;
if(a[i]>1111)
{
cout<<"\n\tEntered Number is not BINARY";
return;
}
i++;
}
i--;
cout<<"\n\tHexadecimal equivalent of "<<BIN<<" (Binary) is ";
for( ;i>=0; i--)
{
switch(a[i])
{
case 0:
cout<<"0";
break;
case 1:
cout<<"1";
break;
case 10:
cout<<"2";
break;
case 11:
cout<<"3";
break;
case 100:
cout<<"4";
break;
case 101:
cout<<"5";
break;
case 110:
cout<<"6";
break;
case 111:
cout<<"7";
break;
case 1000:
cout<<"8";
break;
case 1001:
cout<<"9";
break;
case 1010:
cout<<"A";
break;
case 1011:
cout<<"B";
break;
case 1100:
cout<<"C";
break;
case 1101:
cout<<"D";
break;
case 1110:
cout<<"E";
break;
case 1111:
cout<<"F";
break;
default:
cout<<"\n\t Entered Number is not BINARY";
return;
}
}
}
{
DEC=NUM;
int i=0, n, arr[10];
while(NUM!=0)
{
n=NUM%2;
arr[i]=n;
NUM=NUM/2;
i++;
}
cout<<"\n\tBinary equivalent of "<<DEC<<" (Decimal) is ";
for(i--; i>=0; i--)
cout<<arr[i];
}
{
DEC=NUM;
int i=0, n;
intarr[10];
while(NUM!=0)
{
n=NUM%8;
arr[i]=n;
NUM=NUM/8;
i++;
}
cout<<"\n\tOctal equivalent of "<<DEC<<" (Decimal) is ";
for(i--; i>=0; i--)
cout<<arr[i];
}
{
DEC=NUM;
int i=0, n;
intarr[10];
while(NUM!=0)
{
n=NUM%16;
arr[i]=n;
NUM=NUM/16;
i++;
}
cout<<"\n\tHexadecimal equivalent of "<<DEC<<" (Decimal) is ";
{
OCT=NUM;
int a[20], i=0;
while(NUM!=0)
{
a[i]=NUM%10;
NUM=NUM/10;
if(a[i]>7)
{
cout<<"\n\tEntered Number is not OCTAL";
return;
}
i++;
}
i--;
cout<<"\n\tBinary equivalent of "<<OCT<<" (Ocatl) is ";
for( ;i>=0; i--)
{
switch(a[i])
{
case 0:
cout<<"000";
break;
case 1:
cout<<"001";
break;
case 2:
cout<<"010";
break;
case 3:
cout<<"011";
break;
case 4:
cout<<"100";
case 5:
case 6:
case 7:
break;
cout<<"101";
break;
cout<<"110";
break;
cout<<"111";
break;
}
}
}
{
OCT=NUM;
unsigned long i=0, a, p=1;
while(NUM!=0)
{
a=NUM%10;
if(a>7)
{
cout<<"\n\tEntered Number is not OCTAL";
return;
}
NUM=NUM/10;
i=i+a*p;
p=p*8;
}
cout<<"\n\tDecimal equivalent of "<<OCT<<" (Ocatl) is "<<i;
}
//Octal to Hexadecimal
Conversion
{
OCT=NUM;
unsigned long i=0, a, p=1;
while(NUM!=0)
{
a=NUM%10;
if(a>7)
{
cout<<"\n\tEntered Number is not OCTAL";
return;
}
NUM=NUM/10;
i=i+a*p;
p=p*8;
}
int j=0, n;
intarr[10];
while(i!=0)
{
n=i%16;
arr[j]=n;
i=i/16;
j++;
}
cout<<"\n\tHexadecimal Equivalent of "<<OCT<<" (Octal) is ";
for(j--; j>=0; j--)
{
if(arr[j]==10)
cout<<"A";
else if(arr[j]==11)
cout<<'B';
else if(arr[j]==12)
cout<<'C';
else if(arr[j]==13)
cout<<'D';
else if(arr[j]==14)
cout<<'E';
else if(arr[j]==15)
cout<<'F';
else
cout<<arr[j];
}
}
//Hexadecimal to Binary
Conversion
{
int i;
cout<<"\n\tBinary equivalent of "<<NUM1<<" (Hexadecimal) is ";
for(i=0; NUM1[i]!=NULL; i++)
{
switch(NUM1[i])
{
case '0':
cout<<"0000";
break;
case '1':
cout<<"0001";
break;
case '2':
cout<<"0010";
break;
case '3':
cout<<"0011";
break;
case '4':
cout<<"0100";
break;
case '5':
case '6':
case '7':
case '8':
case '9':
case 'a':
case 'A':
case 'b':
case 'B':
case 'c':
case 'C':
case 'd':
case 'D':
case 'e':
case 'E':
case 'f':
case 'F':
default:
cout<<"0101";
break;
cout<<"0110";
break;
cout<<"0111";
break;
cout<<"1000";
break;
cout<<"1001";
break;
cout<<"1010";
break;
cout<<"1011";
break;
cout<<"1100";
break;
cout<<"1101";
break;
cout<<"1110";
break;
cout<<"1111";
break;
cout<<"\n\tEntered Number is not
HEXADECIMAL.";cout<<"\n\tPrinted value is not
correct.";
return;
}
}
}
//Hexadecimal to Octal
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'a':
case 'A':
case 'b':
case 'B':
case 'c':
case 'C':
case 'd':
case 'D':
case 'e':
case 'E':
case 'f':
case 'F':
default:
}
}
i--;
for( ;i>=0; i--)
{
h=h+a[i]*m;
m=m*16;
}
i=0;
break;
a[i]=2;
break;
a[i]=3;
break;
a[i]=4;
break;
a[i]=5;
break;
a[i]=6;
break;
a[i]=7;
break;
a[i]=8;
break;
a[i]=9;
break;
a[i]=10;
break;
a[i]=11;
break;
a[i]=12;
break;
a[i]=13;
break;
a[i]=14;
break;
a[i]=15;
break;
cout<<"\n\t Entered Number is not
HEXADECIMAL.";cout<<"\n\t Printed value is not
correct.";
break;
//Hexadecimal to Decimal
Conversion
{
inti,a[20];
unsigned long int h=0, m=1;
cout<<"\n\t Decimal equivalent of "<<NUM1<<" (Hexadecimal) is ";
for(i=0;NUM1[i]!=NULL;i++)
{
switch(NUM1[i])
{
case '0':
a[i]=0;
break;
case '1':
a[i]=1;
break;
case '2':
a[i]=2;
break;
case '3':
a[i]=3;
break;
case '4':
a[i]=4;
break;
case '5':
a[i]=5;
break;
case '6':
a[i]=6;
break;
case '7':
a[i]=7;
break;
case '8':
a[i]=8;
break;
case '9':
a[i]=9;
break;
case 'a':
case 'A':
a[i]=10;
break;
case 'b':
case 'B':
a[i]=11;
break;
case 'c':
case 'C':
case 'd':
case 'D':
case 'e':
case 'E':
case 'f':
case 'F':
default:
a[i]=12;
break;
a[i]=13;
break;
a[i]=14;
break;
a[i]=15;
break;
cout<<"\n\t Entered Number is not
HEXADECIMAL.";cout<<"\n\t Printed value is not
correct.";
break;
}
}
i--;
for( ;i>=0; i--)
{
h=h+a[i]*m;
m=m*16;
}
cout<<h;
}
void Mat_Add()
//Matrix Addition
{
if((m==p)&&(n==q))
cout<<"\n\t Matrices can be added\n";
else
{
cout<<"\n\tMatrices cannot be added\n";
return;
}
cout<<"\n\tEnter the elements of Matrix A ("<<m<<"x"<<n<<"): \n";
for(i=0; i<m; i++)
{
cout<<"\t";
for(j=0; j<n; j++)
cin>>A[i*n+j];
}
cout<<"\n\tEnter the elements of Matrix B ("<<p<<"x"<<q<<"): \n";
for(i=0; i<p; i++)
{
cout<<"\t ";
for(j=0; j<q; j++)
cin>>B[i*q+j];
}
cout<<"\n\tThe Sum of two matrices is: ";
for(i=0; i<m; i++)
{
cout<<"\n\t ";
for(j=0; j<n; j++)
{
cout.setf(ios::right);
cout<<(A[i*n+j]+B[i*q+j])<<" ";
}
}
}
void Mat_Sub()
//Matrix Subtraction
{
if((m==p)&&(n==q))
cout<<"\n\tMatrices can be subtracted\n";
else
{
cout<<"\n\tMatrices cannot be subtracted\n";
return;
}
cout<<"\n\tEnter the elements of Matrix A ("<<m<<"x"<<n<<"): \n";
for(i=0; i<m; i++)
{
cout<<"\t ";
for(j=0; j<n; j++)
cin>>A[i*n+j];
}
cout<<"\n\tEnter the elements of Matrix B ("<<p<<"x"<<q<<"): \n";
for(i=0; i<p; i++)
{
cout<<"\t ";
for(j=0; j<q; j++)
cin>>B[i*q+j];
}
cout<<"\n\t Difference of two matrices is: ";
for(i=0; i<m; i++)
{
cout<<"\n\t ";
for(j=0; j<n; j++)
{
cout.setf(ios::right);
cout.setf(ios::showpos);
cout<<(A[i*n+j]-B[i*q+j])<<" ";
}
}
void Mat_Multi()
//Matrix Multiplication
{
C = new int[m*q];
if((n==p))
cout<<"\n\tMatrices can be multiplied\n";
else
{
cout<<"\n\tMatrices cannot be multiplied\n";
return;
}
cout<<"\n\tEnter the elements of Matrix A ("<<m<<"x"<<n<<"): \n";
for(i=0; i<m; i++)
{
cout<<"\t ";
for(j=0; j<n; j++)
cin>>A[i*n+j];
}
cout<<"\n\tEnter the elements of Matrix B ("<<p<<"x"<<q<<"): \n";
for(i=0; i<p; i++)
{
cout<<"\t ";
for(j=0; j<q; j++)
cin>>B[i*q+j];
}
for(i=0; i<m; i++)
{
for(j=0; j<q; j++)
{
C[i*q+j]=0;
for(ip=0; ip<n; ip++)
C[i*q+j]+=(A[i*n+ip]*B[ip*q+j]);
}
}
cout<<"\n\tThe Product of two matrices is ("<<m<<"x"<<q<<"): ";
for(i=0; i<m; i++)
{
cout<<"\n\t";
for(j=0; j<q; j++)
cout<<C[i*q+j]<<" ";
}
}
void Mat_Trans()
{
//Matrix Transpose
int size;
cout<<"\n\tEnter the size of square matrix \n";
cout<<"\t ";
cin>>size;
A = new int[size*size];
cout<<"\n\t Enter the elements of Matrix ("<<size<<"x"<<size<<"): \n";
for(i=0; i<size; i++)
{
cout<<"\t ";
for(j=0; j<size; j++)
cin>>A[i*size+j];
}
cout<<"\n\t Transpose of the given matrix is: \n";
for(i=0; i<size; i++)
{
cout<<"\t ";
for(j=0; j<size; j++)
cout<<A[j*size+i]<<" ";
cout<<"\n";
}
}
void Mat_Inv()
//Matrix Inverse
{
int a[3][3];
float b[3][3];
float det=0;
cout<<"\n\tEnter the elements of matrix (3x3): \n";
for(i=0; i<3; i++)
{
cout<<"\t ";
for(j=0; j<3; j++)
cin>>a[i][j];
}
for(i=0;i<3;i++)
det += (a[0][i]*(a[1][(i+1)%3]*a[2][(i+2)%3]-a[1][(i+2)%3]*a[2][(i+1)%3]));
cout<<"\n\tInverse of matrix is: \n";
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
b[i][j]=((a[(i+1)%3][(j+1)%3]*a[(i+2)%3][(j+2)%3])(a[(i+1)%3][(j+2)%3]*a[(i+2)%3][(j+1)%3]))/det;
}
for(i=0; i<3; i++)
{
cout<<"\t ";
for(j=0; j<3; j++)
{
cout.setf(ios::fixed);
cout.setf(ios::showpos);
cout.setf(ios::right);
cout<<setprecision(1)<<b[j][i]<<" ";
}
cout<<"\n";
}
}
void Root_equ()
{
float root1, root2;
double discriminant = b*b-4*a*c;
if(discriminant>0)
{
root1=(-b+sqrt(discriminant))/(2.0*a);
root2=(-b-sqrt(discriminant))/(2.0*a);
cout<<"\n\tRoots are REAL and UNEQUAL"<<endl;
cout<<"\n\tRoot 1: "<<root1<<", Root 2:"<<root2;
}
else if(discriminant<0)
{
root1=-b/(2.0*a);
cout<<"\n\tRoots are REAL and EQUAL"<<endl;
cout<<"\n\tRoot 1: "<<root1<<", Root 2:"<<root1;
}
else
cout<<"\n\tRoots are COMPLEX and IMAGINERY";
}
void Equ_root()
{
if(S>0)
cout<<"\n\tQuadratic equation formed is: x*x - "<<S<<"x + "<<P;
else
cout<<"\n\tQuadratic equation formed is: x*x + "<<S<<"x + "<<P;
a=1;
b=-S;
c=P;
cout<<"\n\t Coefficients are: a="<<a<<", b="<<b<<", c="<<c<<endl;
double discriminant = b*b-4*a*c;
double sqroot = sqrt(discriminant);
double root1=(-b+sqroot)/(2.0*a);
double root2=(-b-sqroot)/(2.0*a);
cout<<"\n\t Two numbers whose sum is "<<S<<" and product is "<<P<<"
are:"<<endl;
void main()
{
start1:
start2:
do
{
clrscr();
cout<<endl;
cout<<"\t**********************************"<<endl;
cout<<"\t*
SCIENTIFIC CALCULATOR *"<<endl;
cout<<"\t**********************************"<<endl;
cout<<"\n
1.BASIC OPERATIONS";
cout<<"\n
2.BASE CONVERSIONS";
cout<<"\n
3.MATRIX OPERATIONS";
cout<<"\n
4.MATHEMATICAL OPERATIONS";
cout<<"\n
5.QUADRATIC EQUATION";
cout<<"\n
6.COMPLEX NUMBERS";
cout<<"\n
7.EXIT";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>7)
{
cout<<"\n\tInvalid Choice !!!!";
cout<<"\n\tWant to continue? (y/n)...";
ch=getch();
if(ch=='y'||ch=='Y')
continue;
else
exit(0);
}
switch(ch)
{
case 1:
do
{
clrscr();
cout<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\t~BASIC OPERATIONS MENU
~"<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\n
1.ADDITION";
cout<<"\n
2.SUBTRACTION";
cout<<"\n
3.MULTIPLICATION";
cout<<"\n
4.DIVISTION";
cout<<"\n
5.MODULUS";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>5)
{
cout<<"\n\t Invalid Choice !!!!";
goto A;
}
cout<<"\n\t Enter two numbers: ";
cin>>n1>>n2;
switch(ch)
{
case 1: cout<<"\t Sum of "<<n1<<" and "<<n2<<" is:
";cout<<(n1+n2);
break;
case 2: cout<<"\t Difference of "<<n1<<" and "<<n2<<" is: ";
cout<<(n1-n2);
break;
case 3: cout<<"\t Product of "<<n1<<" and "<<n2<<" is: ";
cout<<(n1*n2);
break;
case 4: cout<<"\t Division of "<<n1<<" and "<<n2<<" is: ";
cout<<((double)n1/(double)n2);
break;
case 5: cout<<"\t Modulus of "<<n1<<" and "<<n2<<" is: ";
cout<<(n1%n2);
break;
}
A:
cout<<"\n\n\t Want to continue? (y/n)...";
choice1=getch();
clrscr();
}while(choice1=='y'||choice1=='Y');
break;
case 2:
do
{
clrscr();
cout<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\t~CONVERSION MENU
~"<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\n
1.BINARY CONVERSION";
cout<<"\n
2.OCTAL CONVERSION";
cout<<"\n
3.DECIMAL CONVERSION";
cout<<"\n
4.HEXADECIMAL CONVERSION";
cout<<"\n
5.Back to MAIN MENU";
cout<<"\n\n\t Enter your choice: ";
cin>>ch;
if(ch<1||ch>5)
{
cout<<"\n\t Invalid Choice !!!!";
cout<<"\n\t Want to continue? (y/n)...";
choice1=getch();
if(choice1=='y'||choice=='Y')
continue;
else
exit(0);
}
switch(ch)
{
case 1:
do
{
clrscr();
cout<<endl;
cout<<"\t---------------------------------"<<"\n";
cout<<"\tBINARY CONVERSION MENU-<<"\n";
cout<<"\t---------------------------------"<<"\n";
cout<<"\n
1.BINARYtoOCTAL";
cout<<"\n
2.BINARYtoDECIMAL";
cout<<"\n
3.BINARYtoHEXADECIMAL";
cout<<"\n\n\t Enter your choice: ";
cin>>ch;
if(ch<1||ch>3)
{
cout<<"\n\t Invalid Choice !!!!";
goto B1;
}
cout<<"\n\t Enter a binary number: ";
long int NUM;
cin>>NUM;
switch(ch)
{
case 1: Bin2Oct(NUM);
break;
case 2: Bin2Dec(NUM);
break;
case 3: Bin2Hex(NUM);
break;
}
B1:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice2;
}while(choice2=='y'||choice2=='Y');
break;
case 2:
do
{
clrscr();
cout<<endl;
cout<<"\t----------------------------------"<<endl;
cout<<"\tOCTAL CONVERSION MENU
-"<<endl;
cout<<"\t----------------------------------"<<endl;
cout<<"\n
1.OCTALtoBINARY";
cout<<"\n
2.OCTAL toDECIMAL";
cout<<"\n
3.OCTAL to HEXADECIMAL";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>3)
{
cout<<"\n\t Invalid Choice !!!!";
goto B2;
}
cout<<"\n\t Enter an Octal Number: ";
switch(ch)
{
case 1:
intNUMi;
cin>>NUMi;
Oct2Bin(NUMi);
break;
case 2:
case 3:
}
B2:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice2;
clrscr();
}while(choice2=='y'||choice2=='Y');
break;
case 3:
do
{
clrscr();
cout<<endl;
cout<<"\t-----------------------------------"<<endl;
cout<<"\tDECIMAL CONVERSION MENU-"<<endl;
cout<<"\t-----------------------------------"<<endl;
cout<<"\n
1.DECIMALtoBINARY";
cout<<"\n
2.DECIMALtoOCTAL";
cout<<"\n
3.DECIMALtoHEXADECIMAL";
cout<<"\n\n\t Enter your choice:";
cin>>ch;
if(ch<1||ch>3)
{
cout<<"\n
Invalid Choice !!!!";
goto B3;
}
cout<<"\n\t Enter a decimal number: ";
int NUM;
cin>>NUM;
switch(ch)
{
case 1:
Dec2Bin(NUM);
break;
case 2:
Dec2Oct(NUM);
break;
case 3:
Dec2Hex(NUM);
break;
}
B3:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice2;
clrscr();
}while(choice2=='y'||choice2=='Y');
break;
case 4:
do
{
clrscr();
cout<<endl;
cout<<"\t --------------------------------------\n";
cout<<"\tHEXADECIMAL CONVERSION MENU-\n";
cout<<"\t---------------------------------------\n";
cout<<"\n
1.HEXADECIMALtoBINARY";
cout<<"\n
2.HEXADECIMALtoOCTAL";
cout<<"\n
3.HEXADECIMAL toDECIMAL";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>3)
{
cout<<"\n\t Invalid Choice !!!!";
goto B4;
}
cout<<"\n\t Enter a hexadecimal number: ";
char NUMc[20];
gets(NUMc);
switch(ch)
{
case 1:
Hex2Bin(NUMc);
break;
case 2:
Hex2Oct(NUMc);
break;
case 3:
Hex2Dec(NUMc);
break;
}
B4:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice2;
clrscr();
}while(choice2=='y'||choice2=='Y');
break;
case 5:
goto start2;
}
}while(choice1=='y'||choice1=='Y');
break;
case 3:
do
{
clrscr();
cout<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\t~
MATRIX OPERATION MENU
~"<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\n
1.ADDITION";
cout<<"\n
2.SUBTRACTION";
cout<<"\n
3.MULTIPLICATION";
cout<<"\n
4.TRANSPOSE";
cout<<"\n
5.INVERSE";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
cout<<"\n";
if(ch<1||ch>5)
{
cout<<"\n\t Invalid Choice !!!!";
goto C;
}
if(ch==1||ch==2||ch==3)
{
cout<<"\t Input rows and columns of matrix A \n";
cout<<"\t ";
cin>>m>>n;
cout<<"\t Input rows and columns of matrix B \n";
cout<<"\t ";
cin>>p>>q;
A = new int[m*n];
B = new int[p*q];
}
switch(ch)
{
case 1:
case 2:
case 3:
case 4:
case 5:
Mat_Add();
break;
Mat_Sub();
break;
Mat_Multi();
break;
Mat_Trans();
break;
Mat_Inv();
break;
}
C:
cout<<"\n\t Want to continue? (y/n)...";
cin>>choice1;
clrscr();
}while(choice1=='y'||choice1=='Y');
break;
case 4:
do
{
sub:
clrscr();
cout<<endl;
cout<<"\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<<"\t~
MATHEMATICAL OPERATIONS MENU ~\n";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<<"\n
1.TRIGONOMATRIC FUNCTIONS";
cout<<"\n
2.HYPERBOLIC FUNCTIONS";
cout<<"\n
3.EXPONENTIAL & LOGARITHMIC FUNCTIONS ";
cout<<"\n
4.POWER FUNCTIONS";
cout<<"\n 5.ROUNDING, ABSOLUTE Value & REMAINDER FUNCTIONS ";
cout<<"\n 6.Back to MAIN MENU";
cout<<"\n\n\t Enter your choice:";
cin>>ch;
if(ch<1||ch>6)
{
cout<<"\n\t Invalid Choice !!!!";
goto D;
}
switch(ch)
{
case 1:
do
{
clrscr();
cout<<endl;
cout<<"\t--------------------------------------"<<endl;
cout<<"\tTRIGONOMETRIC FUNCTIONS MENU-"<<endl;
cout<<"\t--------------------------------------"<<endl;
cout<<"\n
1.sine, sin(x)";
cout<<"\n
2.cosine, cos(x)";
cout<<"\n
3.tangent, tan(x)";
cout<<"\n
4.arc sine, asin(x)";
cout<<"\n
5.arc cosine, acos(x)";
cout<<"\n
6.arc tangent, atan(x)";
cout<<"\n
7.Back to SUB MENU";
cout<<"\n\n\t Enter your choice: ";
cin>>ch;
if(ch==7)
goto sub;
if(ch<1||ch>7)
{
cout<<"\n\t Invalid Choice !!!!";
goto D1;
}
if(ch>=1&&ch<=3)
cout<<"\n\t Enter the value of x (in degrees): ";
else
cout<<"\n\t Enter the value of x: ";
cin>>x;
switch(ch)
{
case 1:cout<<"\t The sine of "<<x<<" degrees i.e.,
sin("<<x<<") is "<<(double)sin(x*PI/180);
break;
case 2: cout<<"\t The cosine of "<<x<<" degrees
i.e., cos("<<x<<") is "<<cos(x*PI/180);
break;
case 3: cout<<"\t The tangent of "<<x<<" degrees
i.e., tan("<<x<<") is "<<tan(x*PI/180);
break;
case 4:cout<<"\t The arc sine of "<<x<<" i.e.,
asin("<<x<<") is "<<asin(x)*180.0/PI<<"
degrees";
break;
case 5:
cout<<"\t The arc cosine of "<<x<<" i.e.,
acos("<<x<<") is "<<acos(x)*180.0/PI<<"
degrees";
break;
case 6:
cout<<"\t The arc tangent of "<<x<<" i.e.,
atan("<<x<<") is "<<atan(x)*180.0/PI<<"
degrees";
break;
}
D1:
cout<<"\n\n\t sWant to continue? (y/n)...";
cin>>choice2;
clrscr();
}while(choice2=='y'||choice2=='Y');
break;
case 2:
do
{
clrscr();
cout<<endl;
cout<<"\t-----------------------------------"<<endl;
cout<<"\tHYPERBOLIC FUNCTIONS MENU
-"<<endl;
cout<<"\t-----------------------------------"<<endl;
cout<<"\n
1.hyperbolic sine, sinh(x)";
cout<<"\n
2.hyperbolic cosine, cosh(x)";
cout<<"\n
3.hyperbolic tangent, tanh(x)";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>3)
{
cout<<"\n\t Invalid Choice !!!!";
goto D2;
}
cout<<"\n\t Enter the value of x: ";
cin>>x;
switch(ch)
{
case 1:
}
D2:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice2;
clrscr();
}while(choice2=='y'||choice2=='Y');
break;
case 3:
do
{
clrscr();
cout<<endl;
cout<<"----------------------------------------------";
cout<<"- EXPONENTIAL AND LOGARITHMIC FUNCTIONS MENU-;
cout<<"----------------------------------------------;
cout<<"\n
1.exponential, e^x";
cout<<"\n
2.natural logarithm, log(x)";
cout<<"\n
3.common logarithm, log10(x)";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>3)
{
cout<<"\n\t Invalid Choice !!!!";
goto D3;
}
cout<<"\n\t Enter the value of x: ";
cin>>x;
switch(ch)
{
case 1:cout<<"\t The exponential of "<<x<<" is ";
cout<<exp(x);
break;
case 2:
{
cout<<"\n\t Enter a number (floating point): ";
cin>>numf;
}
switch(ch)
{
case 1:cout<<"\t Absolute value of "<<num<<" is ";
cout<<abs(num);
break;
case 2:cout<<"\t Round up value of "<<numf<<" is ";
cout<<ceil(numf);
break;
case 3:cout<<"\t Absolute value of "<<numf<<" is ";
cout<<fabs(numf);
break;
case 4:cout<<"\t Round down value of "<<numf<<" is ";
cout<<floor(numf);
break;
}
D5:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice2;
clrscr();
}while(choice2=='y'||choice2=='Y');
break;
case 6: goto start1;
case 7: goto sub;
}
D:
clrscr();
}while(choice1=='y'||choice1=='Y');
break;
case 5:
{
do
clrscr();
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<"~
QUADRATIC EQUATION MENU
~";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
cout<<"\n
1.ROOTS of equation (when the equ. is given) ";
cout<<"\n
2.Equation (when sum & product of no's are given)";
cout<<"\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>2)
{
cout<<"\n\t Invalid Choice !!!!";
goto E;
}
switch(ch)
{
case 1: cout<<"\n\t Enter a, b, c of ax^2 + bx + c: ";
cin>>a>>b>>c;
if(!a)
{
cout<<"\t Value of a cannot be zero"
<<"\n\t Aborting!!!";
}
else
Root_equ();
break;
case 2: cout<<"\n\t Enter sum of the two numbers: ";
cin>>S;
cout<<"\n\t Enter product of the two numbers: ";
cin>>P;
Equ_root();
break;
}
E:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice1;
clrscr();
}while(choice1=='y'||choice1=='Y');
break;
case 6:
{
do
clrscr();
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"~
COMPLEX NUMBERS OPERATION MENU
~"<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\n
1.ADDITION";
cout<<"\n
2.SUBTRACTION";
cout<<"\n
3.MULTIPLICATION";
cout<<"\n
4.DIVISION";
cout<<"\n
5.CONJUGATE";
cout<<"\n
6.MODULUS";
cout<<"\n
7.ARGUMENT";
cout<<"\n
8.POLAR FORM";
cout<<"\n\n\t Enter your choice :";
cin>>ch;
if(ch<1||ch>8)
{
cout<<"\n\t Invalid Choice !!!!";
goto F;
}
int ch1;
while(1)
{
cout<<"\n\t Type of complex number: ";
cout<<"\n
1.a + ib";
cout<<"\n
2.a - ib";
cout<<"\n
Enter your choice (1/2): ";
cin>>ch1;
if(ch1==1||ch1==2)
break;
else
{
cout<<"\n\t Invalid Choice !!!!\n";
continue;
}
}
char signC;
if(ch1==1)
{
sign=1;
signC='+';
}
else
{
sign=-1;
signC='-';
}
if(ch>=1&&ch<=4)
{
cout<<"\n\t Enter the real &imaginery part of a
"<<signC<<" ib for 1st number"<<endl;
cout<<"
a1=";
cin>>a1;
cout<<"
b1=";
cin>>b1;
cout<<"\n\t Enter the real &imaginery part of a
"<<signC<<" ib for 2nd number"<<endl;
cout<<"
a2=";
cin>>a2;
cout<<"
b2=";
cin>>b2;
}
else
{
cout<<"\n\t Enter the real &imaginery part of a
"<<signC<<" ib"<<endl;
cout<<"
a1=";
cin>>a1;
cout<<"
b1=";
cin>>b1;
}
arg=fabs(atan(b1/a1)*180/PI);
if(a1<0&&b1>0)
arg=180-arg;
else if(a1<0&&b1<0)
arg=arg-180;
else if(a1>0&&b1<0)
arg=-arg;
switch(ch)
{
case 1:
r_a=a1+a2;
r_b=b1+b2;
cout.setf(ios::showpos);
cout<<"\n\t Sum of "<<a1<<sign*b1<<"i and
"<<a2<<sign*b2<<"i is ";
cout<<r_a;
cout.setf(ios::showpos);
cout<<sign*r_b<<"i";
break;
case 2:
r_a=a1-a2;
r_b=b1-b2;
cout.setf(ios::showpos);
cout<<"\n\t Difference of "<<a1<<sign*b1<<"i and
"<<a2<<sign*b2<<"i is ";
cout<<r_a;
cout.setf(ios::showpos);
cout<<sign*r_b<<"i";
break;
case 3:
r_a = a1*a2-b1*b2;
r_b = a1*b2+a1*b1;
cout.setf(ios::showpos);
cout<<"\n\t Product of "<<a1<<sign*b1<<"i and
"<<a2<<sign*b2<<"i is ";
cout<<r_a;
cout.setf(ios::showpos);
cout<<sign*r_b<<"i";
break;
case 4:
r_a = (a1*a2+b1*b2)/(a2*a2+b2*b2);
r_b = (a2*b1-a1*b2)/(a2*a2+b2*b2);
cout.setf(ios::showpos);
cout<<"\n\t Division of "<<a1<<sign*b1<<"i and
"<<a2<<sign*b2<<"i is ";
cout<<r_a;
cout.setf(ios::showpos);
cout<<sign*r_b<<"i";
break;
case 5:
cout<<"\n\t Conjugate of "<<a1<<signC<<b1<<"i is ";
cout<<a1;
if(signC=='+')
cout<<-1*b1<<"i";
else
{
cout.setf(ios::showpos);
cout<<+1*b1<<"i";
}
break;
case 6:
cout<<"\n\t Modulus of "<<a1<<signC<<b1<<"i is
"<<sqrt(a1*a1+b1*b1);
break;
case 7:
cout<<"\n\t Argument of "<<a1<<signC<<b1<<"i is ";
cout.setf(ios::fixed);
cout<<setprecision(0)<<arg;
break;
case 8:
cout<<"\t Polar form of complex number
"<<a1<<signC<<b1<<"i is ";
cout.setf(ios::fixed);
cout<<setprecision(1)<<sqrt(a1*a1+b1*b1)<<
"(cos"<<arg<<"+i"<<"sin"<<arg<<")";
break;
}
F:
cout<<"\n\n\t Want to continue? (y/n)...";
cin>>choice1;
clrscr();
}while(choice1=='y'||choice1=='Y');
break;
case 7:
exit(0);
}
clrscr();
}while(choice=='y'||choice=='Y');
}
MAIN MENU
On selecting Option 5 from MAIN MENU and 1 from QUADRATIC EQUATION MENU
On selecting Option 5 from MAIN MENU and 1 from QUADRATIC EQUATION MENU
REFERENCE:
www.google.co.in
www.cplusplus.com
Computer Science C++ SumitaArora