The if and else statement

The if and else statements can be considered as the decision making statements.In simple words its like daily life decisions,for example IF ALIC GOES TO THE PARTY THEN I LL GO ELSE I LL NOT GO.So in programming terms if the first condition is true then else statement ll not be executed.If first condition gets false then else condition ll be executed.

The if and else statement

These are two commands we give to computer and computer do some thing on this behalf. The if statement is used where the condition is dependent on if mean that if some thing happens then do this thing and else statement is used where you need to specify that if this thing does not happen then do some thing else. This is the basic thing in if and else statement. You need to use them on your demand. You can only use if statement or else statement and also you can use them together. You will be then able to get your result as you require. The thing here is the result you want form this statement the statement does not contain any result but if you want to control a airplane then it does matter. You can even use it in a mouse where a click is for if statement and else is for another click. This is the basic thing you need to keep in mind.

The if and else statement

If there are two conditions then we can use IF ELSE statements in the programming language. IF & ELSE statement is two most important & salient features in the C Programming Language. These two statements are used greatly in writing code in C programming language. Now I am giving a very simple example of these two statements in a few words.

Suppose you have to finish a work. You have two options to finish by hiring Michel Or John. Michel is demanding more money than John wants. But you choose that Michel does the work. Then the algorithm is like this;

IF(Michel Agree)
Prinf( Michel will finish the Job);
Else
Prinf(John will work the Job);

The if and else statement

Basically, if-else statement is condition-based statement. Whenever we want to take any action which is based on the outcomes of the given condition, (True or False) , then we need to use the if-else statement.

The syntax for this statement is as follows:

if(condition)

the statement // x1

else

the statement . // x2

If the condition in the syntax is true, then the x1 is executed and if the condition in the syntax is false then x2 is executed. Let us consider an example,

if (y>z)

printf ("the greater no is %d", y); // x1

else

printf("the greater no is %d", z); // x2

Here, if y is greater than z then x1 is executed, otherwise x2 will be executed.

As a whole, if-else statement is totally based on the condition given in the synatax.

Techyv is one of the leading solution providers covering different aspects of Computers and Information Technology. We have a hardworking team of professionals in different areas that can provide you with guaranteed solutions to a blend of your problems. We have a dedicated and devoted team of professional writers with multi-dimensional experience of several years. As a result, we produce quality content on a variety of subjects.