Home
C Examples
How To Print Alphabet From A-Z (Capital Letters) in C Programming | C Programming Examples - 7
Subscribe to:
Post Comments (Atom)
CodeShikhi - The World for Programmers, প্রোগ্রামিং,Learn Programming,Learn Javascirpt | C | C++ | Python | OOP,Learn Programming in Bangla,Bangla Programming Tutorial,Leetcode Problem Solution,BEE Problem Solution,C Programming in Bangla,C in Bangla,Javascript tutorials,C Programming Bangla Tutorial, URI Online Judge Solution in C C++ Python,JavaScript Full Tutorials , OOP Tutorial in C++, Object Oriented Programming in C++,Learn OOP in C++,C Programming Exercise,C Programming Example with Code
// C program to find the print
// Alphabets from A to Z
#include <stdio.h>
int main()
{
// Declare the variables
char ch;
printf("The Alphabets from A to Z are: \n");
// Traverse each character
for (ch = 'A'; ch <= 'Z'; ch++) {
// Print the alphabet
printf("%c ", ch);
}
return 0;
}
The Alphabets from A to Z are: 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
Declare a character variable, say ch .
Initialize loop counter variable from ch = 'A' , that goes till ch <= 'Z' , increment the loop by 1 in each iteration. The loop structure should look like for(ch='A'; ch<='Z'; ch++) .
Inside the loop body print the value of ch .
#include<stdio.h>
int main()
{
int i;
printf("The Alphabets from A to Z are: \n");
for(i=65;i<=90;i++)
{
printf("%c ",i);
}
}
The Alphabets from A to Z are: 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
Here we declared an integer i.
Now this program is same as printing numbers from 65 to 90.
But if you can remember the "ASCII" values of 65 which resembles 'A' and 90 which resembles 'Z' as in ascii sheet. To refer ASCII Values click here.
So instead of "%d " if we use "%c" it is converted to ascii value.
Good
ReplyDeleteThank you
ReplyDeletewords from h
ReplyDeleteFor small letters, ASCII value of a to z is 97 to122 . Small letter 'h' ascii value is 104 . If you want to print from small letter h then start your loop from 104
ReplyDelete