Posted by : Unknown
Saturday, January 30, 2016
If Else command has the following general form
if (condition)
statement 1
else
statement 2
This form has a meaning: if the conditions are right then run pernyataan1 and if the condition is false then it will run pernyataan2
consider the following example:
Example Program If Else
/ * -------------------------------------------- * /
/ * Program: if.cpp * /
/ * -------------------------------------------- * /
#include <stdio.h>
main ()
{
int value, the task;
printf ("enter a value:"); scanf ("% d", & value);
printf ("enter the value of the task:"); scanf ("% d", & tasks);
if (value> 70)
printf ("pass \ n");
else
printf ("do not pass \ n");
}
When the above program is run, the results are as follows:
enter a value: 75
pass
Explanation
of the above program, if input value = 75, then according to the conditions that applied a value> 70, then the statement Passed done. conversely, if the value entered <70, the statement did not pass will be done