Java Learning 2 Conditions and loops

if - then condition

public class Main { Public static void main(String[] args) { if (boolean expression T or F) { //body } else { // do this } } }

alt text

Else If

alt text

loops

for loop

/* Syntax of for loop for ( initialization; condition; increment /decrement){ //body } */

alt textalt text

While Loops

/* Syntax: while (condition) { //body } */

alt text

When to use which loop

use while loop when we don’t know how many time loop run and use for loop when we know how many time does loop run

do while loop

do {

} while (condition);

do while loop executes atleast ones and after that it will check condition

alt text

Q1 Check if the char is at lowercase or uppercase

alt text

Q2. Fibonacci no.

alt text

Q3 count repeated numbers

alt text

Q4. reverse a number

alt text

![alt text](Pastedimage20241117195929.png)