cout<<"========\t\t===================================\n";
cout<<" TYPE\t\t\t\tCALCULATION FORMULA\n";
cout<<"========\t\t===================================\n";
cout<<"\nCONE\t\t\t1/3 x PI X radius x radius x height\n";
cout<<"SPHERE\t\t\t4/3 x PI x radius x radius x radius\n";
cout<<"CYLINDER\t\tPI x radius x radius x height\n";
cout<<"PYRAMID\t\t\t1/3 x width x length x height\n";
cout<<"CUBOID\t\t\twidth x length x height\n";
do
{
cout<<"\n\nEnter the shape (Cone, Sphere, Cylinder, Pyramid or Cuboid): ";
cin>>shape1;
if(strcmp(shape1,"Cone")==0 || strcmp(shape1,"cone")==0)
{
cout<<"\nEnter the radius(m): ";
cin>>a;
cout<<"\nEnter the height(m): ";
cin>>b;
calculate_cone(a,b);
}
else if(strcmp(shape1,"Sphere")==0 ||strcmp(shape1,"sphere")==0)
{
cout<<"\nEnter the radius(m): ";
cin>>a;
b=1;
calculate_sphere(a,b);
}
else if(strcmp(shape1,"Cylinder")==0 || strcmp(shape1,"cylinder")==0)
{
cout<<"\nEnter the radius(m): ";
cin>>a;
cout<<"\nEnter the height(m): ";
cin>>b;
calculate_cylinder(a,b);
}
else if(strcmp(shape1,"Pyramid")==0 || strcmp(shape1,"pyramid")==0)
{
cout<<"\nEnter the width(m):";
cin>>a;
cout<<"\nEnter the length(m):";
cin>>b;
cout<<"\nEnter the height(m):";
cin>>c;
calculate_pyramid(a,b,c);
}
else if(strcmp(shape1,"Cuboid")==0 || strcmp(shape1,"cuboid")==0)
{
cout<<"\nEnter the width(m):";
cin>>a;
cout<<"\nEnter the length(m):";
cin>>b;
cout<<"\nEnter the height(m):";
cin>>c;
{ int d ;
long f_value =0 ;
long f_value1 =0 ;
char color[20] ;
char i [10] ;
char j [10] ;
char k [10] ;
char m [10] ;
char t [10] ;
char cont ;
ifstream infile1("Mini.txt",ios::in) ;
cout<<"\t\t\tResistor Color Codes"<<endl ;
cout<<"\t\t\t********************"<<endl ;
cout<<"Color "<<setw(10)<<" 1st band"<<setw(10)<<" 2nd band"<<setw(10)<<"3rd band"<<setw(10)<<"10*(x)"<<setw(10)<<" Tolerance(+ -)"<<endl<<endl;
if (!infile1 )
{
cout << "Unable to open file";
exit(1);
}
while(infile1>>color>>i>>j>>k>>m>> t)
{
cout<<color<<setw(10)<< i <<setw(10)<< j <<setw(10)<< k <<setw(10)<< m <<setw(10)<< t <<endl;
}
infile1.close() ;
cout<<"\t(Enter color code according to table above,\n\ti.e for Black,please enter 'B')"<<endl ;
do{cout<<"Choose either four band color code or five band color code :"<<endl ;
cin>>d ;
if (d==4)
{ cout<<"\t---><Four band color code><---"<<endl ;
cout<<"Please enter the color code :"<<endl;
getColorCode (colorCode) ;
f_value = getResistorValue(colorCode) ;
cout<<"The resistor value with color code "<<colorCode[0]<<colorCode[1]<<colorCode[2]<<" is "<<f_value<< " Ohm "<<endl ;
cout<<"Continue?(Y/N) :"<<endl;
cin>>cont ;
}
else if(d==5)
{ cout<<"\t---><Five band color code><---"<<endl ;
cout<<"Please enter the color code :"<<endl;
getColorCode1 (colorCode1) ;
f_value1 = getResistorValue1(colorCode1) ;
cout<<"The resistor value with color code "<<colorCode1[0]<<colorCode1[1]<<colorCode1[2]<<colorCode1[3]<<" is "<<f_value1<< " Ohm "<<endl ;
cout<<"Continue?(Y/N) :"<<endl;
cin>>cont ;
}
else
{ cout<<"Sorry,please RE-ENTER a valid code"<<endl;
cout<<"Continue?(Y/N) :"<<endl;
cin>>cont ;
}
}while (cont != 'N') ;
}
void getColorCode (char colorCode[])
{
int i;
for(i = 0; i < 3; i++)
cin>>colorCode[i];
}
long getResistorValue (char colorCode [])
{
int i;
double multiplier;
char band_color;
long value;
double colorValue[3];
You pass C arrays as parameters?
If you try to write data in forbidden memory your program will crash.
Since you're a C++ programmer, you should learn to use what C++ provides.