While Loop in C Programming Language With Examples PDF
While Loop in C Programming Language With Examples PDF
How to Install C
« Previous Next »
First C program
C Keywords
Syntax of the while loop in the C language
Operators in C
Here is the syntax of the while loop in the C language:
Comments in C
while(condition)
Escape Sequence in C {
//code that is to be executed
Constants in C }
C If-else statements Here is the owchart of the while loop in the C language
C Switch Statement
C for loop
Type Casting in C
#include<stdio.h>
C Functions int main(){
int i=1;
C call By Value and Reference
while(i<=10){
printf("%d \n",i);
C Recursive Function
i++;
}
C Arrays
return 0;
}
C 2-Dimensional Array
Output :
C Union Please enter a number of your choice: 20
20 40 60 80 100 120 140 160 180 200
C File Handling
C Preprocessor
https://www.phptpoint.com/while-loop-in-c/ 1/3
3/8/2020 While Loop in C Programming Language with Examples
C Preprocessor
Let's have a look at the properties of the while loop
PHP Training Login/Register
C Error Handling In order to check the condition, a conditional expression is used. Until the
provided condition is failed, the statements de ned within the while loop
C Command Line Arguments
will execute repeatedly.
Storage classes in C The condition will turn out to be true if it returns 0 and it will return non-
zero number, if the condition is false.
Macros In C
The condition expression is mandatory in the while loop.
C Programs
Users can run a while loop without a body.
C Interview Questions
Users can have more than one conditional expression in the while loop.
The braces are optional if the loop body contains only one statement.
Here are 3 examples of the while loop to give you a be er understanding of the
topic: Example 01
#include<stdio.h>
void main ()
{
int j = 1;
while(j+=2,j<=10)
{
printf("%d ",j);
}
printf("%d",j);
}
Output :
3 5 7 9 11
Example 02
#include<stdio.h>
void main ()
{
while()
{
printf("hi Phptpoint");
}
}
Output :
compile time error: while loop can't be empty
Example 03
#include<stdio.h>
void main ()
{
int x = 10, y = 2;
while(x+y-1)
{
printf("%d %d",x--,y--);
}
}
Output :
infinite loop
while(1)
{
//statement
}
« Previous Next »
https://www.phptpoint.com/while-loop-in-c/ 2/3
3/8/2020 While Loop in C Programming Language with Examples
https://www.phptpoint.com/while-loop-in-c/ 3/3