Programming
Fundamentals
using Java🚀Â
Lecture
Â
- statements
- branching
- looping
- coding problems

Statements
Instructions to the JVM to do something.
Â
declarations,
assignments,
methods calls
input/output statements,
classes and objects
etc.
Conditional Statements
Single If
// Single If
int marks = 90;
if (marks > 80) {
//print something
}

Conditional Statements
If-else block
// If-Else Block
int marks = 70;
if (marks > 80) {
//print something
}
else{
//some work
}

Conditional Statements
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
}

Ternary Operator
variable = (condition) ? expressionTrue : expressionFalse;
Loops
Do something again & again!
Â

While Loop

//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;
}
While Loop
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 Loop

for(init;stopping_condition;update_statement){
//execute some stuff
}
Code Demo!
Number SumÂ

Find the sum of numbers from 1 to NÂ
Â
Example
N = 4
Â
Â
Output
10
Number Sum-II

Take input N, followed by N numbers find their sum.
Â
Example
N = 4
Â
Â
Output
10
Prime Number

Given a Number, check if it is Prime or Not!
InputÂ
11
Â
Â
Output
Yes
Sum the Digits

Given a Number, print the sum of its digits.
InputÂ
11
Â
Â
Output
2
Time To Try!



8 Mins
Challenge 🔥Â
Stair Pattern
Â
*
***
*****
Challenge 🔥Â
Triangle Pattern
Â
Â
*
***
*****
Challenge 🔥Â
Print all Primes upto a number N.
Â
Â
Â
Challenge 🔥Â
Print all Primes upto a number N.
Â
Â
Â
Programming fundamentals
By Prateek Narang
Programming fundamentals
- 16