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

Gideon BatureGideon Bature
1 min read

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.

11
Subscribe to my newsletter

Read articles from Gideon Bature directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gideon Bature
Gideon Bature

A Seasoned Software Engineer and Technical Writer.