C if Statement
C if Statement
The if
is a control statement, executes a block of user-defined code only when the condition is true; otherwise, the block will be skipped.
Syntax
The following 4 example programs will help you to understand the if
statement better.
Using Boolean Value
In the below example C program, we will directly hard code the first if
conditional statement to 'true' and the other if
conditional statement to 'false' to get the desired output.
Source Code
Output
Using Number
The conditional statement that returns anything other than 0 (zero) is true
Source Code
Output
Using String
The conditional statement that returns the string datatype is always true.
Source Code
Output
Real World Example
In the below example program, we will check whether the value in a variable x
is greater than 50.
Source Code
Output
Congratulation! you have learned everything about if
statement in C Programming.
Reminder
Hi Developers, we almost covered 98% of String functions and Interview Question on C with examples for quick and easy learning.
We are working to cover every Single Concept in C.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.