goto statement in C

goto is a jump statement used to transfer program control unconditionally from one part of a function to another. I have used the word unconditionally because there is no restriction on control transfer. You can transfer program control from one position to any position within a function. Many programmers uses goto to gain full control on their program.

Read more

Do…while loop in C programming

C programming supports three types of looping statements for loop, while loop and do...while loop. Among three do...while loop is most distinct loop compared to others.

do...while is an exit controlled looping statement. We use do...while loop when there is a need to check condition after execution of loop body. do...while loop in any case executes minimum once.

Read more

For loop in C programming

In real life we come across situations when we need to perform a set of task repeatedly till some condition is met. Such as – sending email to all employees, deleting all files, printing 1000 pages of a document. All of these tasks are performed in loop. To do such task C supports looping control statements.

For loop is an entry controlled looping statement. It is used to repeat set of statements until some condition is met.

Read more

switch…case statement in C

if...else statement provides support to control program flow. if statement make decisions based on conditions. It selects an action, if some condition is met. However, there exits situations where you want to make a decision from available choices. For example – select a laptop from available models, select a menu from available menu list etc.

switch...case statement gives ability to make decisions from fixed available choices. Rather making decision based on conditions. Using switch we can write a more clean and optimal code, that take decisions from available choices.

Read more

Nested if…else statement in C

Simple if and if...else...if statements provide a great support to control programs flow. Simple if is single condition based task i.e. “if some condition is true, then do the task”. In contrast if...else...if statement provides multiple condition checks i.e. “if some condition is true, then do some task. If the condition is false, then check some other condition and do some task. If all conditions fails, then do some default task.”

Read more