print a to z

Discussion in 'C' started by hkp819, Dec 24, 2008.

  1. hkp819

    hkp819 New Member

    Joined:
    Dec 4, 2008
    Messages:
    59
    Likes Received:
    1
    Trophy Points:
    0
    Please tell me how to print a to z on the screen using c/c++
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    printf("ABCDEFGHJKLMNOPQRSTUVWXYZ");
     
  3. heavensgate15

    heavensgate15 New Member

    Joined:
    Mar 18, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    you can use the ASCII code to print a - z.... using for loop, initialize the variable to 97, I think that's the ASCII code of small letter "a".... But to make sure, try check it to the book.... then, the loop will continue until it reaches 122, because that's the ASCII code of small letter "z".... then, print it using %c to print the equivalence of the number..... so this is how your program looks like:

    void main(void)
    {
    int i;

    clrscr();

    for(i = 97; i <= 122; i++)
    printf("%c",i);

    getch();
    }


    OR


    void main(void)
    {
    char letter;

    clrscr();

    for(letter = 'a'; letter <= 'z'; letter++)
    printf("%c",letter);

    getch();
    }
     
  4. hkp819

    hkp819 New Member

    Joined:
    Dec 4, 2008
    Messages:
    59
    Likes Received:
    1
    Trophy Points:
    0
    Thanks for reply.
    It is very useful to me..
    thanks a lot once again..
     
  5. heavensgate15

    heavensgate15 New Member

    Joined:
    Mar 18, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    wokie... please post more problems regarding in C....
     
  6. imported_crmahato

    imported_crmahato New Member

    Joined:
    Mar 9, 2010
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    Printing all alphabets A-Z.

    'C' code is here
    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int i,j,k=65;
    clrscr();
    for(i=0;i<5,i++)
    {
    for(j=0;j<5;j++)
    {
    printf("%c\t",k);
    k++;
    }
    printf("\n");
    }
    getch();
    }
    
    above code will print

    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice