Â
Instructions to the JVM to do something.
Â
declarations,
assignments,
methods calls
input/output statements,
classes and objects
etc.
Single If
// Single If
int marks = 90;
if (marks > 80) {
//print something
}
If-else block
// If-Else Block
int marks = 70;
if (marks > 80) {
//print something
}
else{
//some work
}
If-else-if-else block
// If-Else Block
int marks = 70;
if (marks > 80) {
//do something
}
else if(marks>60){
//do something
}
else{
//do something
}
variable = (condition) ? expressionTrue : expressionFalse;
Do something again & again!
Â
//Init
while(..condition is true ..){
//execute some stuff
//update
}
int calories_burnt = 0;
while(calories_burnt <100 ){
System.out.println("running...");
calories_burnt = calories_burnt + 1;
}
int calories_burnt = 0;
while(calories_burnt<100 ){
System.out.println("running...");
calories_burnt = calories_burnt + 1;
}
//out of the loop
System.out.println("Done");
for(init;stopping_condition;update_statement){
//execute some stuff
}
Find the sum of numbers from 1 to NÂ
Â
Example
N = 4
Â
Â
Output
10
Take input N, followed by N numbers find their sum.
Â
Example
N = 4
Â
Â
Output
10
Given a Number, check if it is Prime or Not!
InputÂ
11
Â
Â
Output
Yes
Given a Number, print the sum of its digits.
InputÂ
11
Â
Â
Output
2
8 Mins
Challenge 🔥Â
Stair Pattern
Â
*
***
*****
Challenge 🔥Â
Triangle Pattern
Â
Â
*
***
*****
Challenge 🔥Â
Print all Primes upto a number N.
Â
Â
Â
Challenge 🔥Â
Print all Primes upto a number N.
Â
Â
Â