Results 1 to 6 of 6

Thread: C++ program for Area of a Trapezoid

  1. #1
    Join Date
    Jul 2006
    Posts
    339

    C++ program for Area of a Trapezoid

    I am new to the C++ programming language. I have written a program for calculating the Area of a trapezoid in C++. The program is not compiling because it is giving an error in the #include <iostream> line. I don't know when does this error generate.?? Do you think that there is something wrong in the C++ application.??
    Last edited by NIcaBoy; 23-01-2010 at 08:24 PM.

  2. #2
    Join Date
    Aug 2006
    Posts
    227

    Re: C++ program for Area of a Trapezoid

    Actually no-one can tell that what exactly problem you are facing.! I think that it will be better if you provide with your code. So that I (also others) can check that the coding of that program are proper or not. And then can provide you the missing things, if any. Also have you tried to run the other program in C++.? Are you getting the same errors in that.? If the other programs are running properly, then there should be something wrong in your coding. But i would recommend you to send your coding.!
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  3. #3
    Join Date
    Jul 2006
    Posts
    339

    Re: C++ program for Area of a Trapezoid

    Here is my program that i have made for calculating Area of a Trapezoid :
    Code:
    #include <iostream>
    using namespace std;
    
    int flip (void);
    
    int main()
    
    {
       cout<<"Now in the flip function" << endl;
       return 1;
    
    
    {double baseOne, baseTwo, baseSum, completebaseSum, Altitude, Area;
    
    cout<<"What is the length of the first base of the Trapezoid?"<<endl;
    cin>> baseOne;
    cout<<"What is the length of the second base of the Treapezoid?"<<endl;
    cin>> baseTwo;
    
    baseSum = (baseOne + baseTwo);
    completebaseSum = (baseSum / 2);
    
    cout<<"What is the altitude of the Trapezoid?"<<endl;
    cin>> Altitude;
    Area = (Altitude * completebaseSum);
    cout<<"The area of the Trapezoid is:"<< Area<< endl;
    
    system("PAUSE");
    
    return 0;
    }

  4. #4
    Join Date
    Aug 2006
    Posts
    227

    Re: C++ program for Area of a Trapezoid

    I think that you have made your program more complicated. I know what using namespace std; does but using that over here seems to be useless. Always try to make your code small as possible. You have also made the syntax errors. The flip function is not defined and it is never called anywhere in the program. So using the flip function in this program is not useful. There are an overuse of variables. I would like to suggest you that avoid using the functions that are not useful in your program. Also I think that there is nothing wrong with your C++ application or the compiler. So try to change the coding.
    I do to dead flowers what people at morgues do to dead people. Suck all the moisture out, dip them in plastic, paint them up pretty and put them in a nice frame.

  5. #5
    Join Date
    Nov 2008
    Posts
    1,192

    Re: C++ program for Area of a Trapezoid

    The following code that I provided may help you to reduce your coding in the program that you have made for calculating the area of trapezoid. Here is the code for that :
    Code:
    int main()
    {
    
    double baseOne, baseTwo, Altitude, Area;
    
    cout<<"What is the length of the first base of the Trapezoid?"<<endl;
    cin>> baseOne;
    
    cout<<"What is the length of the second base of the Trapezoid?"<<endl;
    cin>> baseTwo;
    
    cout<<"What is the altitude of the Trapezoid?"<<endl;
    cin>> Altitude;
    
    Area = (Altitude * (baseOne + baseTwo) / 2.0);
    
    cout<<"The area of the Trapezoid is:"<< Area<< endl;
    
    system("PAUSE");
    return 0;
    
    }

  6. #6
    Join Date
    Mar 2008
    Posts
    672

    Re: C++ program for Area of a Trapezoid

    Hope that this code will also provide you good help..
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int parallelsidea;
        int parallelsideb;
        int height;
        int Area;
    
        cout << "Enter the length of the first parallel side: ";
        cin >> parallelsidea;
    
        cout << endl << "Enter the length of the second parallel side: ";
        cin >> parallelsideb;
    
        cout << endl << "Enter the height: ";
        cin >> height;
    
        Area = (parallelsidea + parallelsideb) / 2 * height;
    
        cout << endl << "Area of the Trapezoid: " << Area << endl;       
        system("pause");
    
        return 0;
    
    }

Similar Threads

  1. Replies: 3
    Last Post: 28-01-2011, 01:57 PM
  2. Windows DEP program continuously closes the MSN mail program
    By Charioteer in forum Windows Software
    Replies: 4
    Last Post: 19-10-2010, 11:52 AM
  3. Running a program under WOW64 on a program X64
    By Pratyush in forum Software Development
    Replies: 2
    Last Post: 08-04-2009, 09:51 PM
  4. End Program ccSvcHst Program not responding
    By Leena in forum Operating Systems
    Replies: 6
    Last Post: 29-08-2008, 01:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,145,765.12821 seconds with 17 queries