Q:

print array values in java using loops

0

print array values in java using for loops, while loops, and do while loops

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

print elements of array using for loop:

int a[]={7,8,6,5,9};
System.out.println("print array elements using for loop:");
for(int i=0;i<=4;i++)
{
System.out.println(a[i]);
}

 

print array values using while loop:

int arr[]={5,6,9,8,7};
int i=0;
while(i<=4)
{
System.out.println(arr[i]); 
i++;
}

 

print array values using do while loop:

int arr[]={5,4,7,3,8};
int i=0;
do 
{
	System.out.println(arr[i]);
	i++;
}
while(i<=4);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now