Free programming examples and instructions

C program to study while loop

C program to study while loop

by Krishna

Posted on 27 Jul 2018 Category: C Views: 1358

C program to study while loop

C while loops statement allows to repeatedly run the same block of code until a condition is met. while loop is a most basic loop in C programming. 
while loop has one control condition, and executes as long the condition is true.

The syntax of a while loop in C programming language is −

while(condition) {

Below shows a sample while loop program and its output

#include <stdio.h>

int main()
    int i, n=5;


     * Print natural numbers from 1 to n
        printf("%d\n", i);

    return 0;


Leave a Comment:

Click here to register

Popular articles