C Program to Print the Alphabet in Lowercase Except m and c

C Program to Print the Alphabet in Lowercase Except m and c

A C program that prints the alphabet in lowercase, except for the letters m and c, followed by a new line, using only the putchar() function.

Play this article

Table of contents

Introduction

This program is going to print all the alphabets from a to z, except for alphabet m and c. We will be using the putchar() function and will be printing a new line at the end.

To achieve this, we will be using the Betty style of coding, and the loop statement, the while loop in particular as well as the if control statement.

#include <stdio.h>
/*
 *main - prints all alphabets except m and c
 *Return: 0
*/
int main(void)
{
    char ch;

    ch = 'a';

    while (ch <= 'z')
    {
        if (ch != 'm' && ch != 'c')
        {
            putchar(ch);
        }
        ch++;
    }
    putchar('\n');
    return (0);
}

If you compile and run the program, you should get a similar result to what is in the image below:

Conclusion

This is one of the many ways or methods this can be done, you can as well try doing the same thing using the for loop.

Thank you for reading, you can connect with me on Twitter and LinkedIn.