Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer12-Jun-16 22:37
leon de boer12-Jun-16 22:37 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 1:25
Hassan Syed113-Jun-16 1:25 
GeneralRe: Large project how to seprate definition and declaration? Pin
Richard MacCutchan13-Jun-16 1:46
mveRichard MacCutchan13-Jun-16 1:46 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer13-Jun-16 4:03
leon de boer13-Jun-16 4:03 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 4:54
Hassan Syed113-Jun-16 4:54 
SuggestionRe: Large project how to seprate definition and declaration? Pin
David Crow13-Jun-16 5:23
David Crow13-Jun-16 5:23 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer13-Jun-16 16:19
leon de boer13-Jun-16 16:19 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed113-Jun-16 19:47
Hassan Syed113-Jun-16 19:47 
This was the whole code from main file. Please divide it in module form like professional people do so that I can exactly see the problem in my understanding of dividing the project into moduler form

C++
/*
-------------------------
Name = Syed Sibt E Hassan
Registration Number = MC160201226
-------------------------
1) Input from the user
2) Function Calls to reactangle and trapezoid
3) Exit loop when input is not 'Y' || 'y'
*/

#include <iostream>
using namespace std;

float rectangleArea (float , float); //Declaration for Rectangle Area
float trapezoidArea (float , float, float); //Declaration for Trapezoid Area.

int main()
{
    int choice = 0;
    char tryagain = 0;
    do
      {
        cout << "\n\nEnter 1 to calculate the area of Rectangle" << endl;
        cout << "Enter 2 to calculate the area of a Trapezoid" << endl;
        cout << "\n\nEnter your choice : ";
        cin >> choice;
            switch(choice)
            {
                         //Dealing with area of Rectangle.
            case 1:
                {

                    float width = 0.0, length = 0.0, answer = 0.0;
                    cout << "Enter the width of rectangle :";
                    cin >> width;
                    cout << "Enter the length of rectangle :";
                    cin >> length;
                    answer = rectangleArea(width, length); //Function Call to Rectangle
                    cout << "The area of Rectangle is : " << answer << endl;
                    break;
                }

                         //Dealing with area of Trapezoid.
            case 2:
                {

                    float base1 = 0.0, base2 = 0.0, height = 0.0, answer = 0.0;
                    cout << "Enter base1 of trapezoid : ";
                    cin >> base1;
                    cout << "Enter base2 of trapezoid : ";
                    cin >> base2;
                    cout << "Enter the height of trapezoid : ";
                    cin >> height;
                    answer  = trapezoidArea(base1, base2, height); //Function Call to Trapezoid
                    cout << "The area of Trapezoid is : " << answer << endl;
                    break;
                }

            default:{
                cout << "Neither 1 nor 2 entered." << endl;
                }
            }

            cout << "\n Do you want to do another calculation? : ";
            cin >> tryagain;
        }while (tryagain == 'Y' || tryagain == 'y');

    return 0;
}

//Calculation of Rectangle Area.
float rectangleArea (float width, float length)
{
    float Area_Rectange = 0.0;
    Area_Rectange = width * length;
    return (Area_Rectange);
}

//Calculation of Trapezoid Area.
float trapezoidArea (float base1, float base2, float height)
{
    float Area_Trapezoid = 0.0;
    Area_Trapezoid = height * (base1 + base2)/2;
    return (Area_Trapezoid);
}

AnswerRe: Large project how to seprate definition and declaration? Pin
David Crow14-Jun-16 2:47
David Crow14-Jun-16 2:47 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer14-Jun-16 6:06
leon de boer14-Jun-16 6:06 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer14-Jun-16 10:01
leon de boer14-Jun-16 10:01 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed114-Jun-16 20:34
Hassan Syed114-Jun-16 20:34 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 3:53
leon de boer15-Jun-16 3:53 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 4:32
Hassan Syed115-Jun-16 4:32 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 6:21
leon de boer15-Jun-16 6:21 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 7:01
Hassan Syed115-Jun-16 7:01 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 8:04
leon de boer15-Jun-16 8:04 
GeneralRe: Large project how to seprate definition and declaration? Pin
Hassan Syed115-Jun-16 8:48
Hassan Syed115-Jun-16 8:48 
GeneralRe: Large project how to seprate definition and declaration? Pin
leon de boer15-Jun-16 20:00
leon de boer15-Jun-16 20:00 
QuestionGlut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 7:03
Ratul Thakur11-Jun-16 7:03 
AnswerRe: Glut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 20:02
Ratul Thakur11-Jun-16 20:02 
GeneralRe: Glut errors with Mingw on windows Pin
leon de boer11-Jun-16 22:59
leon de boer11-Jun-16 22:59 
GeneralRe: Glut errors with Mingw on windows Pin
Ratul Thakur11-Jun-16 23:59
Ratul Thakur11-Jun-16 23:59 
QuestionWhy no boundry condition set for C++ Pin
Hassan Syed111-Jun-16 4:52
Hassan Syed111-Jun-16 4:52 
AnswerRe: Why no boundry condition set for C++ Pin
Richard MacCutchan11-Jun-16 5:08
mveRichard MacCutchan11-Jun-16 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.