C Language

May 22, 2023

How to use while loop in c language

program to use while loop is c language


#include <stdio.h>
int main()
{
    int i = 1;
    while (i <= 10)
    {
        printf("%d\t", i);
        i = i + 1;
    }
    printf("\n");
    return 0;
}

output


1       2       3       4       5       6       7       8       9       10

Steps Description

  1. Declare integer variable i
  2. initialize integer variable i=1
  3. whil (i=5) condition which needs to be evaluated
  4. printf inbuild function to display the value of %d
  5. code of instructions which need to be executed
  6. i++ increment value

by : Ajaj Khan

Quick Summary:

program to use while loop is c language copy #include &ltstdio.h> int main() { int i = 1; while (i