In some programming cases, we want to take control to the start of the loop, skipping the statements inside the loop, and sometimes we want to jump out of the loop. For these purposes, we have some special statements known as the jump statement in C. They are : break statement continue statement goto statement […]
March 4, 2022 | C | No comments
Here are a few examples of the do-while loop. Printing table of a number using do-while: output: using the do-while loop, the value of ‘i’ is multiplied by 6. The loop continues till the value of ‘i’ is less than or equal to 10. Finally, the table of the given number is printed. Calculating factorial […]
March 3, 2022 | C | No comments
The do-while loop in c in an exit controlled loop unlike the for and the while loop the condition is checked at the end of the loop(i.e, after the execution of all the statements inside the do-while block), therefore the do-while loop runs at least once in the program even if the condition fails. syntax: […]
March 1, 2022 | C | No comments
Let us look at various examples of the while loop in c. Printing n numbers: output: Here, we printed n natural numbers by running a while loop till the temp reaches the nth value. counting digits in a number: output: Here, the number gets divided by 10 repeatedly until the condition becomes false; the count […]
March 1, 2022 | C | No comments
The while loop in c is an entry controlled loop (Entry Controlled Loops are used when checking of a test condition is mandatory before executing the loop body). It is generally used where we don’t know the number of iterations. Syntax of while loop in C: Example: output: Here, we are calculating the sum of […]
February 27, 2022 | C | No comments
Let us take a look at the various ways to use loops in c. Infinite loop An infinite loop in c does not end, in other words, its condition never becomes true and keeps on updating forever. It is also known as an endless loop or indefinite loop. Example: Output: Here for(;;) is an infinite […]
February 27, 2022 | C | No comments
The programs that we have created so far were of limited nature, because on execution, they always perform the same series of actions, in the same way exactly once. Therefore, for times when we need repetitive action, then we make use of loops. Loops in C: In C programming language the repetitive operation is done […]
February 24, 2022 | C | No comments
We had already seen that both if-else and switch in C can be used for decision-making in a program. Let us discuss their similarity and differences. Similarity: In C language, if-else, as well as the switch statement, are the decision-making statements, where an expression gets evaluated on the basis of a condition, i.e., true or […]
February 23, 2022 | C | No comments
The switch statement in C provide us with an alternate way to implement the if-else if ladder in a much more simplified manner because the syntax of the switch statement is much easier to read and write. The syntax for switch statement: here, case value1, case value2…. are the various cases that a user might select. The […]
February 22, 2022 | C | No comments
As we have already seen that the if statement by itself will execute a single statement, or a group of statements when the expression following if evaluates to true, though it does nothing when the expression evaluates to false. Hence, for this distinct case, we need the else statement, which evaluates an expression when the […]
February 19, 2022 | C | No comments