Skip to main content

Posts

Showing posts with the label Programs to try using if else

if else statement, sample programs and programs to try

If else statement It is a decision making statement in C programming language which allows the program to test for oneor more condition(boolean value) and execute set of statements depends on the condition.The statement in the if block is executed if the condition is evaluated to be true.If the condition is false the statements in the else block will be executed. Syntax: if  ( condition)  {     statements in if block  } else {  statements in else block }    Note: in C zero and null values are treated as false any other non zero or non null values are true. the else part is optional. example : #include<stdio.h>  int main()  {  int num; printf("Enter a number \n"); scanf("%d",&num); if(num<10)       { printf("The value is less than 10"); }  else       { printf("The value is greater than 10"); }  return 0;  } if else if statement An if statement can be followed by an optional else if...else statement, which is very useful to test va