Home » C programs » C looping programs

C program to print all uppercase 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 uppercase alphabets from ‘A’ to ‘Z’ using while loop.
Submitted by IncludeHelp, on March 07, 2018

To print the uppercase alphabets from ‘A’ to ‘Z’,

  • We will declare a variable for loop counter (alphabet) and initialize it by 'A' (uppercase ‘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 uppercase 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("Uppercase 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

Uppercase 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 





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.