What does the following nested loop print out?
for (int r=1; r <=5; ++r) {
double x =10.0*r;
for (int c=1; c<=5; ++c) {
System.out.printf("%5.2f",c/x);
}
System.out.println();
}
5.2 is used to control the decimal places(2 decimal places).
Above program prints the pattern as follows:
1/10 2/10 3/10 4/10 5/10
1/20 2/20 3/20 4/20 5/20
1/30 2/30 3/30 4/30 4/30
1/40 2/40 3/40 4/40 5/40
1/50 2/50 3/50 4/50 5/50
(upto 2 decimal places)
What does the following nested loop print out? for (int r=1; r <=5; ++r) { double...
QUESTION 8 What is the exact output of the following nested loop? for (int row = 2; row<10; row += 4){ int column=1; while (column <= 4){ System.out.print(row - column + ""); column += 2; System.out.println(); wo- 1-153 1-1 53 All of these are correct.
Write a Python program (using a nested loop) to print out the following pattern (there is a space between the numbers next to each other). 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1
Write a java program that will print out the following patters. Use nested for loop.101101010110101
What does the following print at the end? int sum=0; int n=1; while(n<11) { sum =sum + n; n=n+4; } System.out.printf("sum is %d%n",sum);
Convert the following nested for loop into a nested while loop: for(i = 1 ; i <= rows; i++) { for (j = 1 ; j <= rows; j++) { if (bombCells[i][j]) { System.out.print(" * "); } else { System.out.print(" . "); } } System.out.println(); }
What will print out when the following code executes? int[] nums = {1, 2, 3, 4, 5, 6}; int count = 0; while (nums[count] % 2 != 0) nums[count+1] ++; count++; System.out.println(count); 0 0 1 02 03 05
Question 28 (1 point) ✓ Saved What does the code fragment print? double x = Math.sqrt (3); double y = 4; if (x + x == y) { System.out.println(x); } else { System.out.println(y); } 4 1
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
What does the following code fragment print? Explain the result? int [] a = new int[10]; for (int i = 0; i < 10; i++) a[i] = 9 - i; for (int i = 0; i < 10; i++) a[i] = a[a[i]]; for (int i = 0; i < 10; i++) System.out.println(a[i]);
What does the following nested loop structure output? count = 1; while (count <= 11) {innerCount = 1 while (innerCount <= (12 - count)/2) {cout << " "; innerCount++;} innerCount = 1; while (innerCount = 1; while (innerCount <= count) {cout << "0"; innerCount++;} cout << endl; count++;} What does the following nested loop structure output? count = 1; while (count <= 10) {innerCount = 1; while (innerCount <= 10) {cout << setw(5) << count * innerCount; innerCount++;} cout <<...