Used for decision making, when the given condition is true.
The if keyword indicates conditional execution of a block.
The condition must evaluate to a boolean value.
Syntax:if(condition)
{
statement1;
}
else
{
statement2;
}
Example:#include
int main() /* Most important part of the program! */
{
int age; /* Need a variable... */
printf( "Please enter your age" ); /* Asks for age */
scanf( "%d", &age ); /* The input is put in age */
if ( age < 100 ) { /* if the age is less than 100 */
printf ("you are pretty young!\n" ); /* just to show you it works... */
}
else if ( age == 100 ) { /* i use else just to show an example */
printf( "you are old\n" );
}
else {
printf( "you are really old\n" ); /* executed if no other statement is */
}
return 0;
}
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1260 / 158797498. Delta: 0.02083 с