0
Problem with code: Sum of many numbers
#include <iostream> using namespace std; void printArray(int arr[], int size) { for(int x=0; x<size; x++) { cout <<arr[x]<< endl; } } int main() { int mainsize; int i; int a; cout<<"Please state the amount of numbers you want to add: "; cin>>mainsize; for(i=0;i>mainsize;i++){ cout<<"Please type the numbers: \n"; cin>>a; int myArr[i]=a; } printArray(myArr, mainsize) ; } }
2 Respuestas
+ 1
in the 2nd for i<mainsize
0
also after cin >> mainsize you can declare the array int myArray[mainsize] and delete the int from the 2nd for