Skip to content
  • About
  • CoursesExpand
    • Problem Solving using C Language
    • Mastering Database Management
    • Linux System Administration
    • Linux and Shell Programming
  • Publications
  • Professional Certificates
  • BooksExpand
    • Books Authored
  • Patents
Download CV

Conditional Statement

> if Statement

An if statement consists of a boolean expression followed by one or more statements.

if (test expression/Condition)
{
      //statements to be executed if the condition is true
}

See Example

> if-else Statement

An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.

if (test expression/Condition)
{
      //statements to be executed if the condition is true
}
else
{
       //statements to be executed if the condition is false
}

See Example

> nested if Statement

You can use an if or else if statement inside another if or else if statement(s).

if (test expression/Condition)
{
      //statements to be executed if the condition is true
}
else
 if (test expression/Condition)
{
       //statements to be executed if the condition is true
}
else if (test expression/Condition)
{
       //statements to be executed if the condition is true
}
else
{
       //statements to be executed if the condition is false
}

See Example

switch Statement

A switch statement allows a variable to be tested for equality against a list of values.

See Example

Nishant Munjal

Coding Humanity’s Future </>

Facebook Twitter Linkedin YouTube Github Email

Tools

  • SIP Calculator
  • Write with AI
  • SamplePHP
  • Image Converter

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2025 - All Rights Reserved

  • About
  • Courses
    • Problem Solving using C Language
    • Mastering Database Management
    • Linux System Administration
    • Linux and Shell Programming
  • Publications
  • Professional Certificates
  • Books
    • Books Authored
  • Patents
Download CV
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok