C If Statement

Last Updated Nov 4, 2015, 07:00:14 PM

If statement in c executes the statement if a particular condition is met. It compares the given condition and checks if the condition is met or not.

If statement works based on the given condition, for example, if a student gets more than 40 marks in the EXAM, print the result as PASS, otherwise print the result as FAILED

c decision making


Example of C If Statement

Try It Now

In the above example, the if statement checks if marks are less than 40? and prints the output as FAILED. The if statement always takes it as boolean meaning TRUE of FALSE.

Pro Tip!

When you are writing utility methods, extensions or specific library functions, it's likely that you won't be able to avoid ifs (and you shouldn't). There isn't a better way to code this little function, nor make it more self-documented than it is:

Other Decision Making Topics you might want to learn

If else Statement in C

Nested If Statements in C

Switch Statement in C