Posts

Showing posts with the label branching and looping

Jumping Statement(break,continue,goto,exit() , return)

                                                      Jumping Statement break continue goto exit() return() Break:- The break statement breaks the execution of the current statement block and executes the first line that follow the block. We use break statement to terminate the loop once the condition gets satisfied.It can be used to end an infinite loop or force to end before its natural end. Syntax:- if(boolean condition) { ;//statements; break; } Example: #include <stdio.h> int main() { char c; for(;;) { printf( "\nPress any key, q to quit: " ); // Convert to character value scanf("%c", &c); if (c == 'q') break; } } // Loop exits only when 'Q' is...

Looping Statements ( For loop ,while loop ,do while)

Image
                     Looping Statements  Executing a statement (or a group of statements) a number of times is called looping, and there are four statements for looping and iteration in C#. loops are used to repeat a lick of code being able to have your program repeatedly execute a block of code is one of the most basic but useful talks in programming.Al loops can do nesting(loops in loops )there are 3 loops in c#.  For loop while loop do while For loop:- The for loop is used when the number of loops is known.    Syntax:- for(i=1;i>1;i++) { printf("ankit c guru"); }  for(<variable> = <equals to example 1,x,a> ; <identifier> > <comparison with>;<identifier<increment/decrement>>) { \\statements; } Example:-print 1 to 100 numbers by for loop. #include<stdio.h> void ...

Branching(simple if,if else,nested if,else if,switch case )

                                                    Branching                                        (simple if,if else,nested if,else if,switch case ) In c language decision making is so important .Program should be able to do logical(bool or True \False) decisions. “IF statement” and “switch statement” are the most popular conditional statements used in C.These statements are used in most of program. Branch is the term given to the code executed in sequence as a result of change in the program’s flow; the program’s flow can be changed by conditional statements in that program.           ...