for (i = 0; i < = 5; i ++).
for (j = i; j < = 5; j ++);
Print f ("India");
उपर्युक्त प्रोग्राम में India कितनी बार प्रिन्ट होगा
(अ) 6
(ब) 21
(स) 36
(द) 30
Answers
Answer:
c option is correct
Explanation:
first loop for row ,it runs 6 time
second loop for coloum,it runs 6 time
so,6*6=36 times loop will run
hence, it print "India" 36 times
Answer:
India will be printed 21 times.
Explanation:
The given code is:
for(i=0;i<=5;i++)
for(j=i;j<=5;j++)
printf("India");
Let's understand the code;
- There are two loops given in the code. The first one is an outer loop and another one is the inner loop.
- The outer loop will run a total of 6 times from 0 to 5.
- And the inner loop will run according to the outer loop variable's values.
When the value of i = 0 ⇒ j will run from 0 to 5 (6 Times)
When the value of i = 1 ⇒ j will run from 1 to 5 (5 times)
When the value of i =2 ⇒ j will run from 2 to 5 (4 times)
When the value of i=3 ⇒ j will run from 3 to 5 (3 times)
When the value of i=4 ⇒ j will run from 4 to 5 (2 times)
When the value of i=5 ⇒ j will run only one time (1 time)
---------------------------------------------------------------------------------------------
Adding all iterations, the total is
6+5+4+3+2+1 = 21
So, India will be printed 21 times.
Option (b) is correct.
#SPJ2