C Language

May 28, 2023

How to use reverse while loop in C Language

Program to use reverse while loop in C Language


#include 
int main()
{
    int k = 10;
    while (k >= 2)
    {
        printf("%d\t", k);
        k = k - 2;
    }
    return 0;
}

output


10  8  6  4  2  

Steps / Description

  • Declare integer variable k = 10
  • Initialize in integer variable k = 10
  • While condition code =2> code is to evulument the value of (i)
  • by : Nadeem Khan

    Quick Summary:

    As log as this number is greater than zero ,then this condition will be true first 10 will be printed, then the condition will be 8, until the condition is false, the condition will be checked