print array in following format
i want print two array in following format
first array= 1,2,3,4,5,6,7,8,9
second array=11,12,13,14,15,16,17,18,19
i want output as:
1 2 3 11 12 13
4 5 6 14 15 16
7 8 9 17 18 19
View Answers
September 14, 2012 at 4:55 PM
Here is a code that displays the array values in the following pattern:
1 2 3 11 12 13
4 5 6 14 15 16
7 8 9 17 18 19
class DisplayArray
{
public static void main(String[] args)
{
int array1[]= {1,2,3,4,5,6,7,8,9};
int array2[]={11,12,13,14,15,16,17,18,19};
int rows = 3;
int columns = 3;
for (int row = 0; row < rows; row++) {
for (int column = 0; column < columns; column++) {
System.out.print(array1[row * columns + column]+" ");
}
System.out.print(" ");
for (int column = 0; column < columns; column++) {
System.out.print(array2[row * columns + column]+" ");
}
System.out.println();
}
}
}
Ads
Related Tutorials/Questions & Answers:
print array in following format
print array in
following format i want
print two
array in
following format
first
array= 1,2,3,4,5,6,7,8,9
second
array=11,12,13,14,15,16,17,18,19
i...; Here is a code that displays the
array values in the
following pattern:
1 2
Print the following format
Print the
following format how to
print the
following format given string "00401121" in java
0-**
1-*
2-*
3-
4
Advertisements
C program to print the following
C program to
print the following Hello,
Some one help me with a "C Program" to
print the
following as output:
4444444
4333334
4322234
4321234
4322234
4333334
4444444 // for input 4. And also
print the following series
print the
following series a b c d e
b c d e
c d e
d e
e
Hi Friend,
Try the
following code:
class StringPattern
{
public static void main(String[] args)
{
String st="abcde
how to print the following pattern
how to
print the
following pattern Hello
hEllo
heLlo
helLo
hellO
pls reply soon its an emergency
class StringPattern
{
public static void main(String[] args)
{
String st="hello
how to print pdf format
how to
print pdf format Hi every body iam doing school project iam using backend as oracle front end java .how to
print student marks list /attendence in pdf
format. please help me. thanks in advance.
Here
How to print the following pattern in java?
How to
print the
following pattern in java? How to
print the
following pattern in java?
he
he is
he is going
he is going in
import java.io.*;
class StringPattern
{
public static void main(String[] args
i want print the following out put
i want
print the
following out put Hello sir i want the
following out put can u provide the program in c#
o/p;
HELLOLLEH
HELLLEH
HELEH
HEH
H
How to Print Array in JavaScript
How to
Print Array in JavaScript
In this section you will learn about
Array in JavaScript.
Array are important part of all programming languages.
Array...;<h2>Click to
print the
array element</h2></p><p><input
JavaScript array print
JavaScript
array print
 ...
print them wherever we wish. Here is the simple example of
array
printing which... have used a for loop to
print all
the elements of the
array.
for(var i
print
print How to
print JFrame All Componant?
Please visit the
following link:
http://www.roseindia.net/java/example/java/swing/Print.shtml
Print
into the stream and, as opposed to
print() method, gets you to the new line after the text
array
will
print only the designated portion of the
array. Validate low and high; if either...array Consider the
following code below. The function printArray accepts a pointer to integer which represents an
array of integer.After
print a form of *
print a form of * *
***
*****
*******
*********
*******
*****
***
*
Post the
format properly
Simple Date Format Example
Following is a simple date
format example made using
Format class. We have
uses a pattern of special characters to date and time
format.
In this example, SimpleDateFormat:class is used to
format date into text and
parse text into date
Sql Date and Time Format
Format'. To understand this example we use the
following syntax
that is used to
format date and time.
SYNTAX:- DATE_
FORMAT(date,
format... Sql Date and Time
Format