title: Using inputted variables in multiple functions in C++
body: <p>I just started learning C++ from scratch last week and on my assignment I have to create a quadratic equation solver through a few files: assign1.cpp which contains my main(), funcs.cpp which contains every function, and a makefile. I'm having trouble pulling everything together.</p>
  
  <p>I have to get the coefficients from a user and return them to a struct with three fields, and use their inputted information in a few functions to solve the equation.</p>
  
  <p>My programming is all over the place, and I got most of the errors to go away with coeff input; in every function and input.variable_name_here for a, b, and c.</p>
  
  <p>Also, he wants us to use parameters.</p>
  
  <p>I'm hardly half way done with the program.</p>
  
  <p>Here's what I've got:</p>
  
  <pre><code>//Program to solve quadratic equation
  
  #include &lt;iostream&gt;
  #include &lt;cmath&gt;
  using namespace std;
  
  //Structure for coefficients to be used
  struct coeff {
      double a;
      double b;
      double c;
  };
  
  //Prototypes?
  double readCoeffs(), equSolver(), discr(), outResults();
  
  //Read coefficients from user
  double readCoeffs() {
  
      coeff input;
  
      cout &lt;&lt; "Enter coefficient a: ";
      cin &gt;&gt; input.a;
      cout &lt;&lt; "Enter coefficient b: ";
      cin &gt;&gt; input.b;
      cout &lt;&lt; "Enter coefficient c: ";
      cin &gt;&gt; input.c;
  
  }
  
  //Solve quadratic equation from user's input
  double equSolver() {
  
      coeff input;
  
      /*
      need to somehow get the discrim variable from discr() to this function
  
      discr();
      */
  
      double solution1 = (pow(input.b, 2) + sqrt(discrim)) / (2 * input.a);
      double solution2 = (pow(input.b, 2) - sqrt(discrim)) / (2 * input.a);
  
  }
  
  //Solves discriminent of quadratic equation
  double discr() {
  
      coeff input;
  
      double discrim = pow(input.b, 2) - (4 * input.a * input.c);
  
  }
  
  /*
  //Display on the screen results of the calculation
  outResults() {
  
      if (//root exists)
          cout &lt;&lt; "Quadratic equation with the following coefficients: \n";
          cout &lt;&lt; "a: " &lt;&lt; value &lt;&lt; "; b: " &lt;&lt; value &lt;&lt; "; c: " &lt;&lt; value &lt;&lt; "\n" &lt;&lt; endl;
          cout &lt;&lt; "has the following roots ";
          cout &lt;&lt; "Root1: " &lt;&lt; value &lt;&lt; "; Root2: " &lt;&lt; value &lt;&lt; "\n" &lt;&lt; endl;
  
      else
          cout &lt;&lt; "Quadratic equation with the following coefficients: ";
          cout &lt;&lt; "a: " &lt;&lt; value &lt;&lt; "; b: " &lt;&lt; value &lt;&lt; "; c: " &lt;&lt; value &lt;&lt; "\n" &lt;&lt; endl;
  
  }
  
  */
  </code></pre>