by Dinesh Thakur Category: Control Structures

In this example, we use two for loops in conjunction with the putchar library function to print all uppercase letters followed by all lowercase letters. The loop variable ch is assumed to be of type char or int. The first for loop prints the uppercase letters as loop variable ch assumes values as ‘A’, 'B’, ... , ‘z’.

 

Then a put char function prints a newline character to move the cursor to the next line on which the second for loop prints the lowercase letters. Note that the same loop variable is used for both for loops. The output is given below.

#include <stdio.h>

void main()

{

        int ch;

        clrscr();

        printf("Print all uppercase letters followed by all lowercase letters on the next line :\n");

        /* print uppercase letters */

        for (ch= 'A'; ch<= 'Z'; ch++)

             putchar(ch);

             putchar ('\n' ) ;

             /* print lowercase letters */

             for (ch= 'a'; ch<= 'z'; ch++)

                  putchar(ch);

                  putchar ('\n') ;

                  getch();

}

      C Program for Print all uppercase letters followed by all lowercase letters on the next line



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles