Among the decision making statements, if- statement is the most simple one.
It checks if the condition is true or not, and if it is true then it executes the block of code inside if otherwise, it will not. The block that is executed is placed within the curly braces({}).
Flowchart for if statement in java:
Syntax of if statement in Java:
| if (boolean expression) { /* if expression is true */ statements... ; /* Execute statements */ } |
Example of if statement in Java:
| public class IfTest { public static void main(String args[]) { int a = 5; if( a < 10) //checks for condition { System.out.println("If statement executed"); } } } |
Output:
In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …
Read MoreIn this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …
Read MoreIn this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …
Read MoreIn this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …
Read MoreIn this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …
Read MoreIn this tutorial, we will write a C program to print half Pyramid using alphabets/characters. Before that, you may go through the following topic in …
Read More