Tagged: while do statement c

while Statement in C Programming Language 23

while loop in C programming language

In this article, we will understand the while loop in C programming language. Let us suppose you want to execute a block of statement 5 times. There is one approach using goto statement as shown below. #include<stdio.h> #include<conio.h> void main() { int i=0; clrscr(); label1: i=i+1; printf(“%d This will be repeated 5 times\n”, i); if(i!=5) goto label1; printf(“End of the program”); getch(); } Output: 1 This will be repeated 5 times 2 This will be repeated 5 times 3 This will be repeated 5 times 4 This will be repeated 5 times 5 This will be repeated 5 times End...

Loops in C Programming 10

Loops in C Programming

Loops in C are used to change the sequence or flow of the program. The basic behavior of the program is that it starts it from the beginning of the program, executes the particular statement only once and proceeds to the next statement. This behavior is continued till the end of the program is reached. But sometimes we need to execute a particular statement more than once. At this point Loops in C plays an important role. Following are the types of Loops in C language we can use in the program: while loop do-while loop for loop statement

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet