Computer Science, asked by amoghvlogs346, 9 months ago

12) What will be the output of the following program?
public class Test{
public static void main(String[] args) {
int count = 1;
while (count <= 15) {
System.out.println(count % 2 == 1 ? "***" : "+++++");
++count;
II end while
// end main
a. 15 times ***
b. 15 times +++++
c. 8 times *** and 7 times +++++
d. Both will print only once​

Answers

Answered by manishadhiman31
1

your answer will be c

please check out

Answered by bhuvna789456
2

Answer:

         The answer is 8 times asterisk and 7 times plus (Option C).

Explanation:

      If the remainder is equal to 1 on dividing the count by 2, it will print asterisk else print plus.

Therefore, for all odd numbers till 15 (1, 3, 5, 7, 9, 11, 13, 15), it will print asterisk, and for all even numbers till 14 (2, 4, 6, 8, 10, 12, 14) it will print plus

Similar questions