The if-else ladder is used to test a set of conditions in sequence. If any of the conditional expression in the sequence is evaluates to true, then it will execute the corresponding code block but if all the condition is false then it will execute a default code present in else block, (which is an optional) and exits whole if-else ladder.
Syntax
if (condition 1)
{
statement(s) 1;
}
else if(condition 2)
{
statement(s) 2;
}
.
.
else if (condition n)
{
statement(s) n;
}
else
{
default statement(s);
}
Flowchart
Program
// use input is positive, negative or zero
Output
Enter a value of a:
The number is positive!
QUESTION:- write a c program to choose a option from user input and display the message.
OUTPUT
[1] Add
[2] Delete
[3] Edit
[4] Exit
Enter a number : 1
Add option selected.
0 Comments