0% found this document useful (0 votes)
8 views1 page

4

The document contains programming tasks including analyzing a loop execution, rewriting a for loop as a while loop, understanding a two-dimensional array, counting digits in a number without loops, and providing outputs for given code snippets. It requires the reader to determine the number of times a loop executes, the order of a matrix, and to produce outputs for various Java code segments. Additionally, it involves converting strings to doubles and performing arithmetic operations.

Uploaded by

manassaraf18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

4

The document contains programming tasks including analyzing a loop execution, rewriting a for loop as a while loop, understanding a two-dimensional array, counting digits in a number without loops, and providing outputs for given code snippets. It requires the reader to determine the number of times a loop executes, the order of a matrix, and to produce outputs for various Java code segments. Additionally, it involves converting strings to doubles and performing arithmetic operations.

Uploaded by

manassaraf18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

v) Give the output of following program segment.

How may time the loop 12]


will be executed: int a, b, sum;
for(a=1, b=10; a<=b; a++,b--)
( sum+=a; System.out.println(sum));

vi) Rewrite the following for loop program segment using while: [2]
for (int i=10, f =1; i>=1; i--)
{ f *=i;
System.out.println( f );

vii) Consider the following two-dimensional array answer the following [2]
questions:
int arril[]={{4,7,1},(1,5,3),(2,8,6}};
a)What is the order of the matrix?
b)Give output: System.out.println( arr[ 11[3] * arr[2][1]);

viii) Joy wanted to count the number of digits in a given number without using [2]
loop. Write the correct statements to help him?

ix) Show the output of the following program segment? [2]


int a=2; int b=40;
while ( a<=10)
{

++ a;
System.out.println( (++a +b--));
}

x) Give the output of the following code snippet: [2]


String x= "125.15";
String y= "100.06"
double a=Double. parseDouble(x);
double b=Double. parseDouble(y);
System.out.println( a + b);

You might also like