0
anyone can help me to fix some problem in c++ it's about array
I created a program about array it's store the input by user and output it by using array and for loop .however it output the address of the array also need to print it 5 number per row #include<iostream> using namespace std; int main(){ int n,num; cout<<"How many integers to enter? "; cin>>n; int data[n][5]; //datatype arrayname[arrarsize]; for(int i=0; i<n ; i++){ cout<<"?"; cin>>num; } cout<<"The input integers are:"<<endl; for(int a=0; a<n ; a++){ cout<< data[a]<<" "; } cout<<endl; return 0; }
2 Respuestas
0
it might help you
sorry to say i cant understand your question properly..
becoz..
i not understand why you not take a array of int num
if you want to 5 five value
and
second point..
you not provide any value to the data taking by the user...
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"How many integers to enter? ";
cin>>n;
. int num[n];
int data[n][5]; //datatype arrayname[arrarsize];
for(int i=0; i<n ; i++){
cout<<"?";
cin>>num[i];
}
cout<<"The input integers are:"<<endl;
for(int a=0; a<n ; a++){
. data[a][5]=num[a]
cout<< data[a][5]<<" ";
}
cout<<endl;
return 0;
}
https://code.sololearn.com/cpKSGa2El017/?ref=app
0
Thanks your reply a lot
Because my skills in array is not very well haha this is my first time to write a program with array arr
It’s mean five numbers in 1row
For example if there are 8 number input .it display 5 number in one row another 3 numbers will display one the next row
2D array or use if statement better?