My First C++ Program: Area, Volume Etc. Calculator - My first program!

free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > C, C++ & Visual C++

My First C++ Program: Area, Volume Etc. Calculator - My first program!

Simba49
CODE
//This program calculates the perimeter, area, surface area, or volume of any shape or solid.

#include <iostream>
#include <string>
#define PI 3.14159265359
using namespace std;


float psquare (float a)
{
return (4*a);
}

float prectangle (float w, float l)
{
return ((2*w)+(2*l));
}

float pparallelogram (float b, float h)
{
return ((2*b)+(2*h));
}

float ptrapezoid (float s, float t, float b)
{
return ((2*s)+b+t);
}

float pcircle (float r)
{
return (PI*r*2);
}

float pellipse (float r, float s)
{
return (PI*(r+s));
}

float ptriangle (float a, float b, float c)
{
return (a+b+c);
}


float asquare (float a)
{
return (a*a);
}

float arectangle (float l, float w)
{
return (l*w);
}

float aparallelogram (float b, float h)
{
return (h*b);
}

float atrapezoid (float t, float b, float h)
{
return (h/2*(t+b));
}

float acircle (float r)
{
return (PI*r*r);
}

float aellipse (float r, float s)
{
return (PI*r*s);
}

float atriangle (float b, float h)
{
return (b*h/2);
}



float scube (float a)
{
return (a*a*6);
}

float vcube (float a)
{
return (a*a*a);
}

float scylinder (float r, float h)
{
return ((2*PI*r*h)+(2*PI*(r*r)));
}

float vcylinder (float r, float h)
{
return (PI*(r*r)*h);
}

float scone (float r, float s)
{
return ((s*PI*r)+(PI*(r*r)));
}

float vcone (float r, float h)
{
return (1/3*PI*(r*r)*h);
}

float ssphere (float r)
{
return (4*PI*(r*r));
}

float vsphere (float r)
{
return (4/3*PI*(r*r*r));
}

float sprism (float B, float P, float h)
{
return ((2*B)+(P*h));
}

float vprism (float B, float h)
{
return (B*h);
}

float spyramid (float B, float s, float l, float n)
{
return (B+n*(1/2*s*l));
}

float vpyramid (float B, float h)
{
return (1/3*B*h);
}

float ppentagon (float a)
{
return (5*a);
}

float phexagon (float a)
{
return (6*a);
}

float apentagon (float a, float s)
{
return (a*s*5/2);
}

float ahexagon (float a, float s)
{
return (a*s*6/2);
}











int main ()

{
    dimension:
    string d, s, t, p;
    float x, y, z, h, perimeter, area, average;
    char n;
    cout <<"Is your shape 2D or 3D?:";
    cin >> d;


    
    if ( (d == "2d") || (d == "2D") || (d == "2") )
    
    
    {

        type:
        cout <<"Are you determining (perimeter or area)?:";
        cin >> t;
        if ( (t == "perimeter") || (t == "Perimeter") || (t == "p") || (t == "P") ) {t="perimeter";} else if ( (t == "Area") || (t == "area") || (t == "a") || (t == "A") ) {t="area";}
        if ( (t == "perimeter") || (t == "area") )
        {

            shape:
            cout <<"What shape is it \n(square, rectangle, parallelogram, trapezoid, circle, ellipse, triangle)?:";
            cin >> s;

            if ( (s == "Square") || (s == "square") || (s == "s") || (s == "S") ) {s="square";} else if ( (s == "Rectangle") || (s == "rectangle") || (s == "R") || (s == "r") ) {s="rectangle";} else if ( (s == "parallelogram") || (s == "Parallelogram") || (s == "p") || (s == "P") ) {s="parallelogram";} else if ( (s == "trapezoid") || (s == "Trapezoid") || (s == "trap") || (s == "Trap") ) {s="trapezoid";} else if ( (s == "Circle") || (s == "circle") || (s == "C") || (s == "c") ) {s="circle";} else if ( (s == "Ellipse") || (s == "ellipse") || (s == "E") || (s == "e") ) {s="ellipse";} else if ( (s == "triangle") || (s == "Triangle") || (s == "t") || (s == "T") ) {s="triangle";}
            if ( (s == "square") || (s == "rectangle") || (s == "parallelogram") || (s == "trapezoid") || (s == "circle") || (s == "ellipse") || (s == "triangle") )
            {
                if (s == "square")
                    { goto square;
                } else if (s == "rectangle")
                    { goto rectangle;
                } else if (s == "parallelogram")
                    { goto parallelogram;
                } else if (s == "trapezoid")
                    { goto trapezoid;
                } else if (s == "circle")
                    { goto circle;
                } else if (s == "ellipse")
                    { goto ellipse;
                } else if (s == "triangle")
                    { goto triangle;
                }


square:

                if (t == "perimeter")
                {
                cout <<"What is the length of a side?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << psquare (x) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the length of a side?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << asquare (x) << ".\n";
                goto end;
                }

rectangle:

                if (t == "perimeter")
                {
                cout <<"What is the length of the rectangle?:";
                cin >> x;
                cout <<"\nWhat is the width of the rectangle?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << prectangle (x,y) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the length of the rectangle?:";
                cin >> x;
                cout <<"\nWhat is the width of the rectangle?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << arectangle (x,y) << ".\n";
                goto end;
                }

parallelogram:

                    if (t == "perimeter")
                {
                cout <<"What is the base of the parallelogram?:";
                cin >> x;
                cout <<"\nWhat is the height of the parallelogram?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << pparallelogram (x,y) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the base of the parallelogram?:";
                cin >> x;
                cout <<"\nWhat is the height of the parallelogram?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << aparallelogram (x,y) << ".\n";
                goto end;
                }

trapezoid:

                if (t == "perimeter")
                {
                cout <<"What is the length of the top?:";
                cin >> y;
                cout <<"\nWhat is the length of the bottom?:";
                cin >> z;
                cout <<"\nWhat is the length of th side?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << ptrapezoid (x, y, z) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the length of top?:";
                cin >> x;
                cout <<"\nWhat is the length of bottom?:";
                cin >> y;
                cout <<"\nWhat is the height of the trapezoid?:";
                cin >> z;
                cout <<"The " << t << " of the " << s << " is " << atrapezoid (x, y, z) << ".\n";
                goto end;
                }

circle:

                if (t == "perimeter")
                {
                cout <<"What is the radius of the circle?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << pcircle (x) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the radius of the circle?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << acircle (x) << ".\n";
                goto end;
                }

ellipse:

                if (t == "perimeter")
                {
                cout <<"What is the first radius?:";
                cin >> x;
                cout <<"\nWhat is the second radius?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is aproximately " << pellipse (x,y) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the first radius?:";
                cin >> x;
                cout <<"\nWhat is the second radius?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << aellipse (x,y) << ".\n";
                goto end;
                }

triangle:

                    if (t == "perimeter")
                {
                cout <<"What is the length of side1?:";
                cin >> y;
                cout <<"\nWhat is the length of side2?:";
                cin >> z;
                cout <<"\nWhat is the length of side3?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << ptriangle (x, y, z) << ".\n";
                goto end;
                }
                else if (t == "area")
                    {
                cout <<"What is the base of the triangle?:";
                cin >> x;
                cout <<"\nWhat is the height of the triangle?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << atriangle (x, y) << ".\n";
                goto end;
                }


            }
            else {
                goto shape;
            }

        }
        else {
            goto type;
        }
    } else if ( (d == "3d") || (d == "3D") || (d == "3") )
    
    
    {

        typ:
        cout <<"Are you determining (surfacearea or volume)?:";
        cin >> t;
        if ( (t == "surfacearea") || (t == "Surfacearea") || (t == "surface") || (t == "Surface") || (t == "s") || (t == "S") ) {t="surface area";} else if ( (t == "Volume") || (t == "volume") || (t == "v") || (t == "V") ) {t="volume";}
        if ( (t == "surface area") || (t == "volume") )
        {

            shap:
            cout <<"What shape is it \n(cube, prism, cylinder, pyramid, cone, sphere)?:";
            cin >> s;

            if ( (s == "Cube") || (s == "cube") || (s == "c") || (s == "C") ) {s="cube";} else if ( (s == "Prism") || (s == "prism") || (s == "P") || (s == "p") ) {s="prism";} else if ( (s == "cylinder") || (s == "Cylinder") || (s == "cy") || (s == "CY") ) {s="cylinder";} else if ( (s == "pyramid") || (s == "Pyramid") || (s == "PY") || (s == "py") ) {s="pyramid";} else if ( (s == "Cone") || (s == "cone") || (s == "CO") || (s == "co") ) {s="cone";} else if ( (s == "Sphere") || (s == "sphere") || (s == "S") || (s == "s") ) {s="sphere";}
            if ( (s == "cube") || (s == "prism") || (s == "cylinder") || (s == "pyramid") || (s == "cone") || (s == "sphere") )
            {
                if (s == "cube")
                    { goto cube;
                } else if (s == "prism")
                    { goto prism;
                } else if (s == "cylinder")
                    { goto cylinder;
                } else if (s == "pyramid")
                    { goto pyramid;
                } else if (s == "cone")
                    { goto cone;
                } else if (s == "sphere")
                    { goto sphere;
                }

cube:

                if (t == "surface area")
                {
                cout <<"What is the length of a side?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << scube (x) << ".\n";
                goto end;
                }
                else if (t == "volume")
                    {
                cout <<"What is the length of a side?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << vcube (x) << ".\n";
                goto end;
                }

cylinder:

                if (t == "surface area")
                {
                cout <<"What is the radius of the base?:";
                cin >> x;
                cout <<"\nWhat is the height of the cylinder?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << scylinder (x, y)   << ".\n";
                goto end;
                }
                else if (t == "volume")
                    {
                cout <<"What is the radius of the base?:";
                cin >> x;
                cout <<"\nWhat is the height of the cylinder?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << vcylinder (x, y)   << ".\n";
                goto end;
                }

cone:

                if (t == "surface area")
                {
                cout <<"What is the radius of the base?:";
                cin >> x;
                cout <<"\nWhat is the slant length of the cone?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << scone (x, y)   << ".\n";
                goto end;
                }
                else if (t == "volume")
                    {
                cout <<"What is the radius of the base?:";
                cin >> x;
                cout <<"\nWhat is the height of the cone?:";
                cin >> y;
                cout <<"The " << t << " of the " << s << " is " << vcone (x, y)   << ".\n";
                goto end;
                }

sphere:

                if (t == "surface area")
                {
                cout <<"What is the radius of the sphere?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << ssphere (x) << ".\n";
                goto end;
                }
                else if (t == "volume")
                    {
                cout <<"What is the radius of the sphere?:";
                cin >> x;
                cout <<"The " << t << " of the " << s << " is " << vsphere (x) << ".\n";
                goto end;
                }

prism:
                cout <<"What shape is the face of the " << s  <<"?\n";
                cout <<"(triangle, rectagle, pentagon, hexagon):";
                cin >> p;
                if ( (p == "triangle") || (p == "Triangle") || (p == "t") || (p == "T") ) {p="triangular";} else if ( (p == "Rectangular") || (p == "rectangular") || (p == "R") || (p == "r") ) {p="rectangular";} else if ( (p == "pentagon") || (p == "Pentagon") || (p == "P") || (p == "p") ) {p="pentagonal";} else if ( (p == "hexagon") || (p == "Hexagon") || (p == "H") || (p == "h") ) {p ="hexagonal";}
                if ( (p == "triangular") || (p == "rectangular") || (p == "pentagonal") || (p == "hexagonal") )
                {
                    if ((t == "surface area") && (p == "triangular"))
                    {
                        cout <<"What is the length of side1 of the triangle?:";
                        cin >> y;
                        cout <<"\nWhat is the length of side2 of the triangle?:";
                        cin >> z;
                        cout <<"\nWhat is the length of side3 of the triangle?:";
                        cin >> x;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        perimeter = ptriangle (x, y, z);
                        cout <<"What is the base of the triangle?:";
                        cin >> x;
                        cout <<"\nWhat is the height of the triangle?:";
                        cin >> y;
                        area = atriangle (x, y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << sprism (area, perimeter, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "surface area") && (p == "rectangular"))
                    {
                        
                
                        cout <<"What is the length of the rectangle?:";
                        cin >> x;
                        cout <<"\nWhat is the width of the rectangle?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        perimeter = prectangle (y, x);
                        area = arectangle (x , y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << sprism (area, perimeter, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "surface area") && (p == "pentagonal"))
                    {
                        cout <<"What is the length of a side on the pentagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the pentagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        perimeter = ppentagon (x);
                        area = apentagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << sprism (area, perimeter, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "surface area") && (p == "hexagonal"))
                    {
                        cout <<"What is the length of a side on the hexagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the hexagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        perimeter = phexagon (x);
                        area = ahexagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << sprism (area, perimeter, h)  << ".\n";
                        goto end;
                    }
                    
                    
                    
                    else if ((t == "volume") && (p == "triangular"))
                    {
                    
                        cout <<"What is the base of the triangle?:";
                        cin >> x;
                        cout <<"\nWhat is the height of the triangle?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        area = atriangle (x, y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vprism (area, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "volume") && (p == "rectangular"))
                    {
                        
                
                        cout <<"What is the length of the rectangle?:";
                        cin >> x;
                        cout <<"\nWhat is the width of the rectangle?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        area = arectangle (x , y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vprism (area, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "volume") && (p == "pentagonal"))
                    {
                        cout <<"What is the length of a side on the pentagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the pentagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        area = apentagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vprism (area, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "volume") && (p == "hexagonal"))
                    {
                        cout <<"What is the length of a side on the hexagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the hexagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the prism?:";
                        cin >> h;
                        area = ahexagon (y, x);
                        cout <<area;
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vprism (area, h)  << ".\n";
                        goto end;
                    }

                } else {
                    goto prism;
                }

pyramid:

                    cout <<"What shape is the face of the " << s  <<"?\n";
                cout <<"(triangle, rectagle, pentagon, hexagon):";
                cin >> p;
                if ( (p == "triangle") || (p == "Triangle") || (p == "t") || (p == "T") ) {p="triangular";} else if ( (p == "Rectangular") || (p == "rectangular") || (p == "R") || (p == "r") ) {p="rectangular";} else if ( (p == "pentagon") || (p == "Pentagon") || (p == "P") || (p == "p") ) {p="pentagonal";} else if ( (p == "hexagon") || (p == "Hexagon") || (p == "H") || (p == "h") ) {p ="hexagonal";}
                if ( (p == "triangular") || (p == "rectangular") || (p == "pentagonal") || (p == "hexagonal") )
                {
                    if ((t == "surface area") && (p == "triangular"))
                    {
                        
                        cout <<"\nWhat is the slant length of the pyramid?:";
                        cin >> x;
                        cout <<"What is the base of the triangle?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the triangle?:";
                        cin >> z;
                        area = atriangle (x, y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << spyramid (area, y, x, 3) << ".\n";
                        goto end;
                    }
                    else if ((t == "surface area") && (p == "rectangular"))
                    {
                        
                
                        cout <<"What is the length of the rectangle?:";
                        cin >> x;
                        cout <<"\nWhat is the width of the rectangle?:";
                        cin >> y;
                        cout <<"\nWhat is the slant length of the pyramid?:";
                        cin >> z;
                        average = (x+y)/2;
                        area = arectangle (x , y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << spyramid (area, average,z,4)  << ".\n";
                        goto end;
                    }
                    else if ((t == "surface area") && (p == "pentagonal"))
                    {
                        cout <<"What is the length of a side on the pentagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the pentagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the slant length of the pyramid?:";
                        cin >> z;
                        area = apentagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << spyramid (area, x, z, 5)   << ".\n";
                        goto end;
                    }
                    else if ((t == "surface area") && (p == "hexagonal"))
                    {
                        cout <<"What is the length of a side on the hexagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the hexagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the slant length of the pyramid?:";
                        cin >> z;
                        perimeter = phexagon (x);
                        area = ahexagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << spyramid (area, x, z, 5)   << ".\n";
                        goto end;
                    }
                    
                    
                    
                    else if ((t == "volume") && (p == "triangular"))
                    {
                    
                        cout <<"What is the base of the triangle?:";
                        cin >> x;
                        cout <<"\nWhat is the height of the triangle?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the pyramid?:";
                        cin >> h;
                        area = atriangle (x, y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vpyramid (area, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "volume") && (p == "rectangular"))
                    {
                        
                
                        cout <<"What is the length of the rectangle?:";
                        cin >> x;
                        cout <<"\nWhat is the width of the rectangle?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the pyramid?:";
                        cin >> h;
                        area = arectangle (x , y);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vpyramid (area, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "volume") && (p == "pentagonal"))
                    {
                        cout <<"What is the length of a side on the pentagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the pentagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the pyramid?:";
                        cin >> h;
                        area = apentagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vpyramid (area, h)  << ".\n";
                        goto end;
                    }
                    else if ((t == "volume") && (p == "hexagonal"))
                    {
                        cout <<"What is the length of a side on the hexagon?:";
                        cin >> x;
                        cout <<"\nWhat is the measurement from the center of the hexagon to a side (apothem)?:";
                        cin >> y;
                        cout <<"\nWhat is the height of the pyramid?:";
                        cin >> h;
                        area = ahexagon (y, x);
                        cout <<"The " << t << " of the " << p << " " << s << " is " << vpyramid (area, h)  << ".\n";
                        goto end;
                    }

                } else {
                    goto pyramid;
                }

            }
            else {
                goto shap;
            }

        }
        else {
            goto typ;
        }
    }
    else {
        goto dimension;
    }
end:
    cout <<"Do you want to calculate an other shape? (y / n):";
        cin >>n;
    if (n == 'y')
    { goto dimension; }
    return 0;
}

 

 

 


Reply

hamza
too complicated and it is not good programming to add goto statments, it makes it complicated and makes it difficult to make changes in it and to read it

Reply

pyost
I agree with the above statement. While GOTO statements can be very useful, they aren't appreciated by full-fledged programmers. As a matter a fact, mine programming teacher has forbidden us to use them during one of the first classes biggrin.gif

As for the rest of the program, it is far to complicated. With all those IF statements you leave the impression of the program not having a mind of its own. What I am trying to say is that it is possible to create such a program that would deal with the same problem, yet with far less lines of code. I do not claim I could do it, but I am absolutely sure it is possible with all C++ has to offer wink.gif

Reply

hamza
and try to use switch statments. i have use this program but it needs effeicency so try to make this program again by not using goto statments and using switch statments

Reply

Jeigh
Wow, yea, as mentioned goto is bad practice. There are a LOT of ways goto can make programs mess up, especially if you ever try to modify code with numerous goto statements. Further you are not taking advantage of the language whatsoever. Write functions to handle things and call them instead of goto statements. Control the user input (tell them what to type) rather then taking into account a shitload of possible string entires (or run the input through the lowercase built in function then take a substring of the first however many letters, and base your assumption off that). Those huge if blocks with tons of or's in it make me cry inside hehe.

You just have SO MUCH code for something that could, as mentioned, be done in a much much much more concise way. Ignoring the fact that most of the functions for this are probably built into c++ even wanting to write your own it could be done in much less code and much cleaner code.

Another tip would be to take all the user input at once, for example get them to enter the length, width, and height as a comma delimited string or just one at a time, hitting enter in between, but list the order beforehand so you dont need to print/input/print/input/print/input every time.

 

 

 


Reply

The Pixel Coder
No need to blame this guy, cool.gif remember this is his very first app, so if it does work, it's very good.

Ofc Symba, my eyes were bleeding too when i saw those goto's, it made me remember of those old DOS Batch scripts...

A switch would be appreciated too, it's more - beautiful - and i think also slightly more efficient...

Gl in your new C++ world!

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. how to write a program that calculates the area of an ellipse - 5.43 hr back. (1)
  2. c program sum of measurements problem and answer - 111.62 hr back. (1)
  3. c program that calculates surface area of a cone - 129.75 hr back. (1)
  4. c surface area of a pyramid program - 151.16 hr back. (1)
  5. c program area of pentagon - 191.84 hr back. (2)
  6. circle, square, rectangle c program - 206.81 hr back. (1)
  7. c pyramid program - 292.90 hr back. (1)
  8. "c surface area of sphere" - 320.17 hr back. (1)
  9. examples of c programs of area and perimeter of a rectangles - 326.41 hr back. (1)
Similar Topics

Keywords : program

  1. C++ Meters To Feet And Feet To Meters Program
    I made it (0)
  2. Math Program
    arithmetical progression problem (2)
    Short program in c to calculate first term when sum of n terms and common difference d is given.....
  3. Fibonacci Number Program Problem
    n00b :) (5)
    I (finaly) started learning C. I'm using a book to learn it combined with some trial and error.
    Now I've made a program to calculate the Fibonacci numbers, but there seems to be some error.
    This is the source code: CODE #include  <stdio.h> main() { int   fib1, fib2,
    fib, i, inp; printf("************************************************");
    printf("\n* Welcome to the Fibonacci Number Program v0.1 *\n");
    printf("************************************************"); printf("\n....
  4. Vc Runtime Lib Error When Run A Program
    (3)
    the program was tested in my machine with VS.net installed. It run without any problem with 24
    hours. However, when I run it in other machine without VS.NET or VC ienvironment, it didn't
    works. Even I installed dot.net framework and copy MFC, VC's dll files to this PC, it just don;t
    run. The following are the dll files that I copied: mfc40.dll mfc40loc.dll mfc40u.dll mfc42.dll
    MFC42CHS.DLL mfc42loc.dll mfc42u.dll MFC71.dll MFC71CHS.DLL MFC71CHT.DLL mfc71d.dll MFC71DEU.DLL
    MFC71ENU.DLL MFC71ESP.DLL 2005-04-01 01:02 61,440 MFC71FRA.DLL 2005-04-01 01:02 61,440 MFC7....

    1. Looking for program

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for program
advertisement




My First C++ Program: Area, Volume Etc. Calculator - My first program!



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE