Posts

Showing posts with the label if else program

If and If-Else Program

Image
If statement :- The if statement evaluates the test expression inside parentheses. If test expression is evaluated to true ( nonzero ), statements inside the body of if is executed. If test expression is evaluated to false ( 0 ), statement inside the body of if is skipped. Flow Chart of if statement :- Basic if syntax :- if ( statement is TRUE ) { /* between the braces is the body of the if statement */ Execute all statements inside the body } Example :- Ques - Program to Print number is even. #include <iostream> //Header file using namespace std; int main () //Main function { int number ; cout<<"Enter a number :"; // Print on the screen cin>>number; // Take input from the console / user. // Test expression is true if number is perfectly divide by 2 if ( number % 2 == 0 ) // % means find remainder , == means perfectly equal { cout<< "Even number" ; ...