Q.F Answer the following question: (Any two) [3]
1. What are infinite loops?
2. Define Conditional statements.
3. What is the use of ‘else’ in for loop?
Answers
1. What are infinite loops?
➡️⤵️
An infinite loop occurs when a condition always evaluates to true. Usually, this is an error. For example, you might have a loop that decrements until it reaches 0. public void sillyLoop( int i ) { while ( i != 0 ) { i-- ; } }
2. Define Conditional statements.
➡️⤵️
A conditional statement is false if hypothesis is true and the conclusion is false. The example above would be false if it said "if you get good grades then you will not get into a good college". If we re-arrange a conditional statement or change parts of it then we have what is called a related conditional.
Answer:
In computer programming, an infinite loop is a sequence of instructions that, as written, will continue endlessly, unless an external intervention occurs. It may be intentional.