Thread: Need help with flowchart

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    8

    Need help with flowchart

    I need help with a flowchart in a question I'm doing. I've completed the programming code but just have no idea on flowcharts if anyone can give me an idea on how to do this then I'll appreciate it. This is the question:

    Write a C++ program that reads from keyboard 3 integers, with proper input prompt, and then displays the maximum sum of any pair of numbers from these three. If the 3 numbers are 5, 6 and 7 for instance, then the maximum sum comes from 6+7=13. Draw the flowchart of this C++ program, and also desk check the program for the three input integers 12, 3 and 7, or a different set of 3 numbers which will make the desk checking less trivial within your program design.

    I've completed the code which is:

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int num1, num2, num3, sum;
        
        cout << "Enter number ";
        cin >> num1;
        
        cout << "Enter number ";
        cin >> num2;
        
        cout << "Enter number ";
        cin >> num3;
        
       /* if(num1 >= num2)
        {
                
                
        }*/
        
        if(num1 > num2 && num3 >
         num2)
        {
                sum = num1 +  num3; 
                cout << "The sum of " << num1 << " and " << num3 << " = " << sum << endl;
        }
        else if(num1 >= num3 && num2 >= num3)
        {
             sum = num1 + num2;         
             cout << "The sum of " << num1 << " and " << num2 << " = " << sum << endl; 
        }
        else if (num2 >= num1 && num3 >= num1)
       {
            sum = num2 + num3; 
            cout << "The sum of " << num2 << " and " << num3 << " = " << sum << endl;
        } 
      //else
      //{
        //  cout << "all three numbers must be diffrent" <<endl;
         // }
         
         system("PAUSE");
         
         return 0;

  2. #2
    INSANE INSIDE ekosix's Avatar
    Join Date
    May 2010
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    First take a look at this flowchart instance: File:LampFlowchart.svg - Wikipedia, the free encyclopedia
    Now, analyse this code based on the flowchart above:
    Code:
    void LampDoesNotWork(void)
    {
       if(LampPluggedIn == false)
       {
          PlugInLamp();
       }
       else if(BulbBurnedOut == true)
       {
          ReplaceBulb();
       }
       else
       {
          BuyNewLamp();
       }
    Well, I think this is what you need. If you understand this, you'll get what you want.
    Just take this exemple and try...
    I would like to see your final results, if possible.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing FlowChart!
    By l2krence in forum Tech Board
    Replies: 1
    Last Post: 11-18-2010, 11:46 PM
  2. flowchart with if else statements
    By nishar in forum Tech Board
    Replies: 2
    Last Post: 10-01-2010, 04:20 PM
  3. Flowchart Software?
    By Cell in forum Tech Board
    Replies: 2
    Last Post: 02-09-2009, 08:20 AM
  4. flowchart. Help!!!
    By chema124 in forum C Programming
    Replies: 3
    Last Post: 12-10-2002, 10:00 AM
  5. Flowchart
    By ob1cnobe in forum C++ Programming
    Replies: 4
    Last Post: 06-05-2002, 12:03 PM