Hello everyone, I am a student in a beginners c++ class and I need some help on an assignment I need to write a code that will "Write a program that reads in two positive integers that are 15 digits in length and then outputs the addition and subtraction of the two numbers." I have to use arrays. This is what I have coded so far

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




int const size=15;

class RLN
{
  private:
        int num1 [15];
        int num2 [15];
        int sum [16];
        int sub [15];
        int x [15];
        int y [15];
  public:
        void get_input();
        void do_add ();
        void is_greater ();
        void do_sub ();
        void print_sum ();
        void print_sub ();
};


void RLN::get_input()
{

 int i;
        for(i=0;i<size;i++)
                cin>>num1[i];
        for(i=0;i<size;i++)
                cin>>num2[i];
      }

void  RLN::do_add ()
{
     sum= num2+num1

   return 0;
}
void  RLN::is_greater ()
{
        if (num1>num2)
{
                x=num1
                y=num2
}
        else
{               x=num2
                y=num1
}
   return 0;
}
void  RLN::do_sub ()
{
        sub=x-y
   return 0;
}
void  RLN::print_sum ()
{
        cout<<"The summation is:"<<endl;
        cout<<sum<<endl:
   return 0 ;
}
void RLN::print_sub ()
{
        cout<<"The subtraction is:"<<endl;
        cout<<sub<<endl;
   return 0;
#include<iostream>
#include<string>
#include "RLN.h"
#include<cmath>
using namespace std;

int const size=15

void RLN::RLN()
{
        int i;
        for (i=0;i<size;i++)
        {
                num1[i]=0;
                num2[i]=0;
                sum[i]=0;
                sub[i]=0;
        }
        sum[i]=0;

}



int main()
{
        class RLN ob1;
        ob1.get_input();
        return 0;
}

Im getting a lot of error messages, and I cannot seem to fix anything. Im still pretty new at coding and this problem is over my head. If anyone could help me out that would most appreciated! Thank you in advance.

Could you please post your error meesages. Also on line 43 in your do_add() function you are doing sum = num1 + num2; You can not do something like this since they are arrays. You would have to write a function to step through the array and add the numbers together at the index and then carry over into the next larger index. this also applies to your other functions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.