Polynomial Program Help

Hi, i'm a beginner in dev c++ and i need to write a program that can add and subtract polynomials.

So far my program asks for the highest power of x, then asks the user to input coefficients based on the power. (for example the user inputs 2 as highest power, the program will ask for coefficients for degree 2, 1, and 0.)

But i put it in a loop so i don't know how it will store the numbers the user inputted and add or subtract them. I'm lost. Help me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
    
    int pow, deg, deg2;
    cout<<"\n\tEnter highest power of x: ";
    cin>>pow;
    int x=pow;
    cout<<"\n\tFirst Polynomial\n";
    do{
             cout<<"\tEnter co-efficient for degree "<<x--<<": ";
             cin>>deg;
             }while(x>=0);       
    cout<<"\n\tSecond Polynomial\n";
    int x2=pow;
    do{
             cout<<"\tEnter co-efficient for degree "<<x2--<<": ";
             cin>>deg2;
             }while(x2>=0);
       cout<<"\n\n\t"<<deg<<"\n\t"<<deg2;
system("PAUSE");
return 0;}
You need a runtime-sized array to store a variable amount of input data.
You can allocate it manually or use something like std::vector.
Topic archived. No new replies allowed.