Control structures and statements in C and C with flow charts. Control structures form the basic entities of a structured programming language. We all know languages like CC or Java are all structured programming languages. Control structures are used to alter the flow of execution of the program. Why do we need to alter the program flow The reason is decision making In life, we may be given with a set of option like doing Electronics or Computer science. We do make a decision by analyzing certain conditions like our personal interest, scope of job opportunities etc. With the decision we make, we alter the flow of our lifes direction. This is exactly what happens in a CC program. We use control structures to make decisions and alter the direction of program flow in one or the other paths available. There are three types of control structures available in C and C1 Sequence structure straight line paths2 Selection structure one or many branches3Loop structure repetition of a set of activitiesAll the 3 control structures and its flow of execution is represented in the flow charts given below. Control statements in CC to implement control structures. All Sorting Program In C Language' title='All Sorting Program In C Language' />We have to keep in mind one important fact all program processes can be implemented with these 3 control structures only. Thats why I wrote control structures are the basic entities of a structured programming language. To  implements these control structures in a CC program, the language provides control statements. So to implement a particular control structure in a programming language, we need to learn how to use the relevant control statements in that particular language. The control statements are Switch. If. If Else. While. Do While. For. As shown in the flow charts Selection structures are implemented using If, If Else and Switch statements. Looping structures are implemented using While, Do While and For statements. Selection structures Selection structure. Selection structures are used to perform  decision making and then branch the program flow based on the outcome of decision making. Selection structures are implemented in CC with If, If Else and Switch statements. If and If Else statements are 2 way branching statements where as Switch is a multi branching statement. Acunetix 7 Crack. The simple If statement. The syntax format of a simple if statement is as shown below. This expression is evaluated. If expression is TRUE statements inside the braces will be executedstatement 1 statement 2 statement 1 Program control is transfered directly to this line, if the expression is FALSEstatement 2 The expression given inside the brackets after if is evaluated first. If the expression is true, then statements inside the curly braces that follow ifexpression will be executed. If the expression is false, the statements inside curly braces will not be executed and program control goes directly to statements after curly braces. All Sorting Program In C Language' title='All Sorting Program In C Language' />Example program to demo If statement. Problem  A simple example program to demo the use of If, If Else and Switch is shown here. An integer value is collected from user. If the integer entered by user is 1 output on screen UNITED STATES. Usmc Lightweight Helmet Manual'>Usmc Lightweight Helmet Manual. If the integer is 2 output SPAIN, If the integer is 3 output INDIA. If the user enters some other value output WRONG ENTRY. Note The same problem is used to develop example programs for if else and switch statementsincludevoid mainint num printfHello user, Enter a number scanfd, num Collects the number from userifnum1printfUNITED STATES ifnum2printfSPAIN ifnum3printfINDIA The If Else statement. Syntax format for If Else statement is shown below. Expression 1 is evaluated. If TRUE, statements inside the curly braces are executed. If FALSE program control is transferred to immedate else if statement. If expression 1 is FALSE, expression 2 is evaluated. If expression 2 is FALSE, expression 3 is evaluatedstatement 1 statement 2 else If all expressions 1, 2 and 3 are FALSE, the statements that follow this else inside curly braces is executed. The execution begins by evaluation expression 1. C-Free-PNG-Image.png' alt='All Sorting Program In C Language' title='All Sorting Program In C Language' />If it is TRUE, then statements inside the immediate curly braces is evaluated. If it is FALSE, program control is transferred directly to immediate else if statement. Here expression 2 is evaluated for TRUE or FALSE. The process continues. If all expressions inside the different if and else if statements are FALSE, then the last else statement without any expression is executed along with the statements 1 and 2 inside the curly braces of last else statement. Example program to demo If Elseincludevoid mainint num printfHello user, Enter a number scanfd, num Collects the number from userifnum1printfUNITED STATES else ifnum2printfSPAIN else ifnum3printfINDIA elseprintfWRONG ENTRY See how else is used to output WRONG ENTRYNote Notice how the use of If Else statements made program writing easier. Compare this with above program using simple If statement only. Switch statement. Switch is a multi branching control statement. Syntax for switch statement is shown below. Expression is evaluated. The outcome of the expression should be an integer or a character constantcase value. Execution of switch statement begins by evaluating the expression inside the switch keyword brackets. The expression should be an integer 1, 2, 1. This expressions value is then matched with each case values. There can be any number of case values inside a switch statements block. If first case value is not matched with the expression value, program control moves to next case value and so on. When a case value matches with expression value, the statements that belong to a particular case value are executed. Notice that last set of lines that begins with default. The word default is a keyword in CC. When used inside switch block, it is intended to execute a set of statements, if no case values matches with expression value. Welcome to the C Tutorial the C developers resources for everything related to the C programming language. If you are Still struggling to get started with C. Title Sorting in math By Heather Rife Primary Subject Math Grade Level K2 Relationship to State Standards Academic Standards and Assessment for. In general, Perl is easier to learn and faster to code in than the more structured C and C languages. Perl programs can, however, be quite sophisticated. Understandable C and C tutorials. Includes compiler setup, basic concepts up to pointers, arrays, classes, recursion, linked lists, and more. Files handling in C C programming language can handle files as Streamoriented data Text files and System oriented data Binary files. So if no case values are matched with expression value, the set of statements that follow default will get executed. Note Notice the break statement used at the end of each case values set of statements. The word break is a keyword in CCused to break from a block of curly braces. The switch block has two curly braces. The keyword break causes program control to exit from switch block. Example program to demo working of switch includevoid mainint num printfHello user, Enter a number scanfd, num Collects the number from userswitchnumcase 1 printfUNITED STATES break case 2 printfSPAIN break case 3 printfINDIA default printfWRONG ENTRY Note Switch statement is used for multiple branching. The same can be implemented using nested If Else statements. But use of nested if else statements make program writing tedious and complex. Switch makes it much easier. Compare this program with above one. Loop structures. Loop Structure. A loop structure is used to execute a certain set of actions for a predefined number of times or until a particular condition is satisfied. There are 3 control statements available in CC to implement loop structures. While, Do while and For statements. The while statement. C Program for Addition Two Array Display Sum of Arrays My C FilesC Program to accept add value of 2 array display the sum of arrays. Reading the 1st arrayn. Enter the  value. Reading the 2nd arrayn. Enter the  value. The output of addition of 2 array isn.