I'm having difficulty finding out how many executions these loops operate sum++. i'm not only interested in the answer but how youy figured it out.
A) for(i=1 ; i<= 100 ; i++)
for (j= 1 ; j <= i; j++) sum++;
A) i'm thinking that the first for loop goes through 100 times and the second for loop is also 100 times so 100^2 is correct?? is this right?
B) for(i = 101; i <=200; i++)
for(j= i - 1; j <i+1;j++) sum++;
B) I tried walking through it and it seems the first loop starts out and goes through 99 times. hen thew second one is true for 99 times so 99^2
my thinking was as follows
1st time through j =100 ; 100 < 101 +1; 100++
2nd time j=101 ; 101 <102+1; 101++
199th time j= 199 ; 199 < 200 +1 ; 200++ so stops here 199-100 = 99 times....is this the right logic??
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects.
Interface Comparable is used to allow objects of a cl…
This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly.
Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…