C program to print all lowercase alphabets using while loop

This is an example of while loop in C programming language - In this C program, we are going to print all lowercase alphabets from 'a' to 'z' using while loop.
Submitted by IncludeHelp, on March 07, 2018

To print the lowercase alphabets from 'a' to 'z',

  • We will declare a variable for loop counter (alphabet) and initialize it by 'a' (lowercase 'a').
  • We will check the condition whether loop counter is less than or equal to 'z', if condition is true numbers will be printed.
  • If condition is false – loop will be terminated.

Program to print all lowercase alphabets from 'a' to 'z' using while loop in C

#include <stdio.h>

int main() {
  //loop counter or a variable that
  //will store initial alphabet,
  //from where we will print the alphabets
  char alphabet;
  //assigning 'a' as initial alphabet
  alphabet = 'a';

  //print statement
  printf("Lowercase alphabets:\n");

  //loop statement, that will check the condition
  //and print the alphabets from 'a' to 'z'
  while (alphabet <= 'z') {
    //printing the alphabets
    printf("%c ", alphabet);
    //increasing the value by 1
    alphabet++;
  }

  return 0;
}

Output

Lowercase alphabets:
a b c d e f g h i j k l m n o p q r s t u v w x y z 

C Looping Programs »

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.