Zero to FAANG (Day 8)-loops

ยท

1 min read

Namaste everyone ๐Ÿ™

Today's learning was so easy. Beacuse today's lecture was about loops and conditions. This two concept I already learnt. But i will give you proof that I understood.

Let's see syntax of if condition.

If(condition) {

// body

}

Let's take an example in Java.

int num=1;

If (num<5){

System.Out.println(num);

} else

{

System.out.println("error");

}

After this I learnt while loop.

Let's see the syntax.

While(condition)

{

//body

//Increment and decrement

}

Let's se example.

Scanner scan=new scanner(system.in);

Int n =scan.nextline();

While (n<7)

{

System.out.println(n);

n++;

}

After this I learnt so while loop.

Let's see if syntax..

Int n= 1;

do{

System.out.println(n)

} While (n<=7);

After this I learn for loop

Let's see it syntax

For(initialization; condition; increment/decrement){

//body

}

Let's see it's example...

For(int n= 1; n<=7; n++)

{

System.out.println(n);

}

So for today's lecture I learnt this things. Than you Kunal.

ย