-->

program to print/display all characters from a to z.

//program  to print/display all characters from a to z.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=97;

while(k<=122)
   {
           printf("%c,",k);
      
    k++;
   }
getch();
}

logic applied:
1)You should know ascii value of all characters then apply that in loop.
ascii value of 'a' is 97 and z is 122.
so apply this value in a loop and print as a character(%c).
or
2)You can use all characters stored in a string and then display one by one.
e.g.
int j;
char string[]="abcdefghijklmnopqrstuvwxyz";
for(j=0;string[j]!='\0';j++)
{
  printf("%c\n",string[j]);
}

put this code in side void main and execute them . you get output.

No comments:

Post a Comment