0

How can i create two dimensional array 15by15 and initialized by an incrementation ?

30th Mar 2017, 3:14 PM
Peshraw Omed
Peshraw Omed - avatar
6 Answers
+ 3
Did you mean? Create 2 dimensional array 15x15 and assign value? what do you mean by incrementation? is it auto increment? if you mean assigning values on runtime here is the code. #include <iostream> using namespace std; int main() { int value; int arr[15][15]; for(int row=0; row<15;row++) { for(int col=0; col<15;col++) { cin>>value; arr[row][col] =value; } } int row=0; while(row<15) { for(int col=0; col<15;col++) { cout<<arr[row][col]; } cout<<endl; row++; } return 0; } If you mean assigning value by auto increment #include <iostream> using namespace std; int main() { int value=0; //value start at 0 int arr[15][15]; for(int row=0; row<15;row++) { for(int col=0; col<15;col++) { arr[row][col] =value; value++; } } int row=0; while(row<15) { for(int col=0; col<15;col++) { cout<<arr[row][col]; } cout<<endl; row++; } return 0; } Hope this helps.
30th Mar 2017, 4:37 PM
Rica Abrigonda
Rica Abrigonda - avatar
+ 2
if you want an all even values just replace the value with value++ in the line arr[row][col] = value; so the for loop sratement should be {arr[row][col] = value++; value++;} and if you want an odd values replace the starting value to 1.
1st Apr 2017, 3:51 AM
Rica Abrigonda
Rica Abrigonda - avatar
+ 2
if you want an all even values just replace the value with value++ in the line arr[row][col] = value; so the for loop sratement should be {arr[row][col] = value++; value++;} and if you want an odd values replace the starting value to 1.
1st Apr 2017, 3:52 AM
Rica Abrigonda
Rica Abrigonda - avatar
0
thanks, I Mean the second one
30th Mar 2017, 5:17 PM
Peshraw Omed
Peshraw Omed - avatar
0
then how can we put the odd and even number from incrementation value I mean auto number but after reversing
30th Mar 2017, 5:21 PM
Peshraw Omed
Peshraw Omed - avatar
0
thanks for your help l appreciate
1st Apr 2017, 12:59 PM
Peshraw Omed
Peshraw Omed - avatar