Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

Decision Control Help

In Programming most of the times you need some statement to be executed when a particular condition is satisfied and some other statement to be executed when other condition is satisfied. To implement this in Programming Languages we need Decision Controls.

Decision Control Statement in C

Whenever an application is built using any programming language so decision Control need to be used in code. By using these statements we can include various conditions in our program using such statements that perform different task based on the conditions. Decision controls emphasis of two terms Control Structure and Decision making. The Control structure is used to alter the flow of execution of the program and decision making is the reason why we need to alter the flow of control in the program. Let's take a real life example it may be given to the set of options like to drink tea or cold coffee. So it makes a decision by analysing certain conditions like the personal choices and depending upon the weather. So decision control is the basic entity of structured programming language and all the languages like C/C++ or Java are structured programming language. Now we are going to discuss some of the Decision control statements are:

If statement: If statement consist a condition that is executed only when the statement is true, otherwise condition is false and compiler shows error. A program can consist any number of if statements.

If-else statement: The statement consists two blocks of statements one for if and other for else. If condition is true, then if block executed and command will go to else block automatically. Both if and else should define at the same time without if else cannot exist.

Switch-case statement: The statement is very useful when the programmer wants to execute several statements of block, means enough number of choices to execute a single statement. Switch defines a block of statements that is based upon the result of expressions, corresponding cases gets executed. A switch statement may have any number of cases with one default handler.

A Decision Control instruction in C can be implemented in C using following:

Decision Control Homework Help

Topics in C Programming

Topics in Programming

Copyright © 2009-2023 UrgentHomework.com, All right reserved.