w3resource logo


C Programming Exercises

C Exercises: Print all the alphabets

Secondary Nav

C Pointer : Exercise-21 with Solution

Write a program in C to print all the alphabets using pointer.
Expected Output :

The Alphabets 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 

C Code:

#include <stdio.h>

int main()
{
    char alph[27];
    int x;
    char *ptr;
 	printf("\n\n Pointer : Print all the alphabets:\n"); 
	printf("----------------------------------------\n");
    ptr = alph;     

    for(x=0;x<26;x++)
    {
        *ptr=x+'A';
        ptr++;
    }
    ptr = alph;

printf(" The Alphabets are : \n");
    for(x=0;x<26;x++)
    {
       printf(" %c ", *ptr);
        ptr++;
    }
    printf("\n\n");
    return(0);
}

Flowchart :

Flowchart: Print all the alphabates

C Practice online:


#include <stdio.h>

int main()
{
    char alph[27];
    int x;
    char *ptr;
 	printf("\n\n Pointer : Print all the alphabates:\n"); 
	printf("----------------------------------------\n");
    ptr = alph;     

    for(x=0;x<26;x++)
    {
        *ptr=x+'A';
        ptr++;
    }
    ptr = alph;

printf(" The Alphabates are : \n");
    for(x=0;x<26;x++)
    {
       printf(" %c ", *ptr);
        ptr++;
    }
    printf("\n\n");
    return(0);
}

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number