Guest User

Untitled

a guest
May 29th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Polynomial {
  5.         int a, b, c, functionValue;
  6.     public:
  7.         Polynomial (int, int, int);
  8.         static void functionValue(Polynomial);
  9.  
  10. };
  11.  
  12. Polynomial::Polynomial (int x, int y, int z) {
  13.  
  14.     a = x;
  15.     b = y;
  16.     c = z;
  17.  
  18. }
  19.  
  20. void Polynomial::functionValue(Polynomial x) {
  21.  
  22.     for (int i = 0; i < 5; i++) {
  23.    
  24.         x.functionValue = x.a * pow(i, 2) + x.b * i + x.c;
  25.         cout << "The value of the function for x = " << i << " is " << x.functionValue;
  26.  
  27.     }
  28.  
  29. }
  30.  
  31. int main () {
  32.  
  33.     Polynomial poly (2, 3, 5);
  34.     Polynomial::functionValue(poly);
  35.  
  36.     system("pause");
  37.     return 0;
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment