PDA

View Full Version : Please Help Anyone!!!!!!


KFerr1080
05-06-2003, 12:56 AM
I hae starte to write my program on how to calculate the derivative of a polyomial... I am confused as in how to do the calculation???? Also I was going to make function called der for a functin prototype......would that be right???? Any suggetions for me???? PLEASE!!!

#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <cmath>

int der( int ); //function prototype

int main()
{
int degree;
int coefficient;
int derivative;
degree = 0;
coefficient =0;
cout << "Enter the degree of the polynomial (or zero to quit): ";
cin >> degree;
if ( degree != 0 )
cout << "Enter the coefficients from highest degree to lowest degree: ";
cin >> coefficient;
if ( degree == 0 )
cout << "Thank you for playing! Please come again!";
derivative = degree * coefficient;

return 0;
} // end main

Spookster
05-06-2003, 02:57 AM
Figure out what the formula for taking the derivative of a polynomial then once you have that it is easy to convert to an expression(s) in code. You should get the formula from your teacher.

You can make functions if you like. You should make a function if you need to do something many times. If you need to calculate something over and over again then put the expressions into a function.

You also need to read our posting guidelines more specifically part 2. Your subject is not appropriate!.

Also you should not have created a new topic when you already have a topic open for this from a few days ago.

http://www.codingforums.com/showthread.php?s=&threadid=19365

dsm1995gst
05-06-2003, 06:30 AM
Originally posted by KFerr1080
using std::cin;
using std::cout;
using std::endl;

Also, you can just type using namespace std; instead of typing out the particulars.