C++ program 05-10-2014, 12:43 PM
#1
Okay, I have a program I am supposed to make using only c++.
It is supposed to allow the user to input int numbers and if the input is '0' the input process is terminated. Then the numbers that were inputed are summed up and displayed.
Problems I had:
-I tried to use Arrays to input but I don't have enough knowledge of how to input to a wide range of elements in an array.
- Thaught I should use array pointers to save memory and allow excess input of about 1000 integers into the array. But same problem as above.
Can someone please provide me with a solution.
My program
(I used eclipse on xubuntu with linux GCC compiler))
Remember to use code tags for code
It is supposed to allow the user to input int numbers and if the input is '0' the input process is terminated. Then the numbers that were inputed are summed up and displayed.
Problems I had:
-I tried to use Arrays to input but I don't have enough knowledge of how to input to a wide range of elements in an array.
- Thaught I should use array pointers to save memory and allow excess input of about 1000 integers into the array. But same problem as above.
Can someone please provide me with a solution.
My program
(I used eclipse on xubuntu with linux GCC compiler))Code:
#include <iostream>
using namespace std;
int main()
{int * arr= new int[1000];
int a=1;
int j;
int i=0;
cout<<"Please input a number below, separate the values by space bar \n"
" Your values will be summed \n";
do{
cin>>arr[i];
}
while (arr[i]!=0);
cout<<arr[i]<<endl;
delete []arr;
return 0;
}Remember to use code tags for code
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)