Jump to content

Need help with a flowchart

- - - - -

  • Please log in to reply
1 reply to this topic

#1
moey187

moey187

    Newbie

  • Members
  • Pip
  • 6 posts
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:


#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
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
A flowchart is nothing more than a graphical block diagram of your source code. Put conditionals (if statements) in diamonds, and draw two lines coming out, one which represents true, and the other false (else clause). Put any non-conditional commands in rectangles. You should mark the start and end points of your program with blocks as well.

Have a look at the Wikipedia article on flowcharts for some examples.
Flowchart - Wikipedia, the free encyclopedia
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users