How to Print Alphabet in C

A simple tutorial to print the entire alphabet using C language. Im using the Dev Cpp Compiler of Bloodshed.net.

Declare a header file

#include<stdio.h>

Put a main() function

int main()
{

}

Declare a variable alpha with a character data type.

char alpha;

We will use a looping structure to repeat the condition from letter ‘A’ to ‘Z’ then display it by using printf() function and format specifier %c together with the variable.

for ( alpha = 'A' ; alpha <= 'Z' ; alpha++)
{
printf("%c ", alpha);
}
return 0;
}

Whole Code:

#include<stdio.h>
int main()
{
char alpha;
for ( alpha = 'A' ; alpha <= 'Z' ; alpha++)
{
printf("%c ", alpha);
}
return 0;
}
Result:


How to Print Alphabet in C How to Print Alphabet in C Reviewed by code-dev on 9:33 PM Rating: 5

No comments:

Powered by Blogger.