Learn C Language

Learn C Programming Language Step By Step. It’s easy to learn c programming language with real-life examples and hands-on. We are trying our best to deliver quality content.

Control Flow In C

[adinserter name="Block 7"]

« Previous Page                                                                                                                             Next Page »

The program is a set of instructions. Each instruction of the program is executed by the processor. In addition, the processor executes instructions one by one. Whatever you will write in your program will be executed in the same order as they appear in the program.

So, it’s clear that the processor executes an instruction in a sequential fashion. At a particular instant, the processor is executing some line of code, which means control of the processor is on that line. The processor’s control moves from one line to another. This movement of the processor is called a control flow in c language.

Types of control flow in c

  • Decision control flow or Decision making
  • Iterative control flow or looping
  • Switch case-control flow
  • control statements (break, continue, goto)

Decision control instruction

Decision control instruction or decision making is also called as decision control flow in c language. It is also known as a selection control instruction. The main function of this control instruction is to select a set of code for execution on the basis of some condition.

Types of decision control flow in c:

  • if
  • if-else
  • conditional operator
  • nested if-else (You may consider)

Iterative Control Instruction

Iterative control instruction, mostly known as the loop is also called as iterative control flow in c language. It is also called repetitive control instruction. Sometimes, it is desirable to execute the same statement again and again.

There are three ways to implement loops in c

  • while
  • do-while
  • for

Switch Case-Control Instruction

Switch case-control is used when you are making a program where multiple choices are involved. The switch transfers the control to a case written in its body depending upon the value evaluated by expression in switch parenthesis.

In switch bodies, each case is postfixed by a constant. This constant could be an integer or a character but not really. It is important to note that the constant in each case must be distinct.

When the value of expression does not match with any case constant then control flow moves on the default segment. In addition, once control moves from a switch to an appropriate case, it will not only execute statements written in that case but also execute all the statements in the following cases including default. However, it will not execute the cases written above that particular case.

If you want to execute only one case execution, you must use the break keyword at the last statement of each case.

Goto Control Instruction

The goto statement is used for the unconditional jump from one part of the program to another part of the program. However, it is always suggested not to use a goto statement because this reduces the readability of the program. I would recommend you to hardly or not use the goto statement because the use of the goto statement is considered a poor programming approach.

The goto is a keyword that moves control to a location in the program mentioned by location name ‘label’. In addition, the goto statement can move the control in forward as well as backward in the program. It’s important to note that goto works only within the same function body.

 [adinserter name=”Block 7″]

Top Book Suggestion

The two books on C Programming Language that I Personally Recommend. I really loved reading these books. These books are listed for quality content, easy steps, and affordable price. You can get it from Amazon and Flipkart. 

Check The Price On Amazon:

1. C Programming Beginner’s Guide

2. Head First C: A Brain-Friendly Guide

Check The Price On Flipkart:

1. Introduction to C Programming 

2. Head First C: A Brain-Friendly Guide

« Previous Page                                                                                                                             Next Page »

[adinserter block=”6″]

Buy Premium Courses At Lowest Price. Become A Certified Developer Today!

Best Books Selected by Our Experts

Buy Premium Projects At Lowest Price

Ebooks Written by Our Experts

CoursePot.Com

Buy Premium Courses At Lowest Price. Grab Golden Opportunity To Become A Certified Developer Today!

Useful Links

Pin It on Pinterest

Share This