0
create a program: array 5 containers and input numbers, get the numbers then add all and display the answers
:'(
4 Réponses
0
// i dunno if u want a single or a double dimensional array so am giving u a double dimensional array of 3 rows and 3 columns
class matrix
{
void matrixSum( int Y [][])
{
int sum = 0;
// the following statements prints the above input array Y[][] in matrix form
System.out.println("Output matrix");
for (int j = 0; j<3; j++) // this loop manages row indexes
{
for (int k = 0; k<3; k++)// this loop manages column indexes
{
System.out.print(Y[j][k]+"\t"); // matrix print statement. DO NOT USE println() HERE
sum = sum + Y[j][k]; // adding all elements
} // for 'k' loop ends here
System.out.println(); // must be used to print array in matrix form. It changes line
}// for 'j' loop ends here
System.out.println(" Sum of odd numbers = "+sum);
}
}
+ 1
please explain more
0
Hope this helps 😊😆
0
thanks