Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Add two dynamic user input arrays?

$
0
0
#include <iostream>
#include <new>
using namespace std;
void business (int num[], int num2[]);
int main ( )
{
  int i,j,k;
  int * p, *pt;
  cout << "How many numbers would you like add? ";
  cin >> i;
  cout << "What would you like to add?";
  cin >> j;
  cout << "+";
  cin >> k;
  business (i,j,k);

  delete[] p;
  return 0;
}

void business (int )
{
    int n;

    for (n=0; n<i; n++)
    {
      cout << "Enter number: ";
      cin >> p[n];
    }
    cout << "You have entered: ";
    for (n=0; n<i; n++)
      cout << p[n] << ", ";
      cout << p[n] + p[n];
}



So i want to make the function business to obtain the numbers and add them to each other. What am I doing wrong here?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>