C uses the keyword if to implement the decision control instruction. The general form of if statement looks like this:


if ( this condition is true )

execute this statement ;

The keyword if tells the compiler that what follows is a decision control instruction. The condition following the keyword if is always enclosed within a pair of parentheses. If the condition, whatever it is, is true, then the statement is executed. If the condition is not true then the statement is not executed; instead the program skips past it.

As a general rule, we express a condition using C’s ‘relational’ operators. The relational operators allow us to compare two values to see whether they are equal to each other, unequal, or whether one is greater than the other. Here’s how they look and how they are evaluated in C.

Sample program to execute C Program :

main( )
{
int num ;
printf ( "Enter a number less than 10 " ) ;
scanf ( "%d", &num ) ;
if ( num <= 10 ) printf ( "What an obedient servant you are !" ) ; } On execution of this program, if you type a number less than or equal to 10, you get a message on the screen through printf( ). If you type some other number the program doesn’t do anything. The following flowchart would help you understand the flow of control in the program. 70.1
The previous post of the blog deals with Operators in C Programming.

Related Posts :

Instructions to write a good C Program
Variables in C Programming
Constants in C programming

You can browse COMPLETE C PROGRAMMING COURSE here.

Thank you for visiting PROGRAMMING BLOG. If you liked the post, please subscribe to my blog via email or RSS FEED.You can contact me here for any specific feed back .

I am requesting your's feedback.

Are you satisfied with the present post ?
Have you got sufficient information you are looking for here at this post and on the blog ?
What else is missing and what topics have to be incorporated in this blog ?
Let me know so that i can make it better .

COMMENT HERE and thank you for sparing your valuable time.

I will be very glad if you share this page on your social book marking site with the below link.

Share/Save/Bookmark

0 comments

Post a Comment