Q:

C program to check a given character is a lowercase character or not without using the library function

0

C program to check a given character is a lowercase character or not without using the library function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Given a character, we have to check whether the given character is a lowercase character or not without using the library function.

Program:

The source code to check a given character is a lowercase character or not without using the library function is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.

// C program to check a given character is a lowercase character or not
// without using library function

#include <stdio.h>

int isLowercase(char ch)
{
    if (ch >= 'a' && ch <= 'z')
        return 1;

    return 0;
}

int main()
{
    char ch;

    printf("Enter character: ");
    scanf("%c", &ch);

    if (isLowercase(ch))
        printf("Given character is a lowercase character\n");
    else
        printf("Given character is not a lowercase character\n");

    return 0;
}

Output:

RUN 1:
Enter character: q
Given character is a lowercase character

RUN 2:
Enter character: G
Given character is not a lowercase character

Explanation:

In the above program, we created two functions isLowercase() and main(). The isLowercase() function is used to check the given character is a lowercase character or not.

In the main() function, we read a character from the user and check given character is a lowercase character or not by calling isLowercase() function and print the appropriate message on the console screen.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C programming Basic Input, Output, if else, Ternary Operator based Programs

Similar questions


need a help?


find thousands of online teachers now
C program to check a given character is a punctuat... >>
<< C program to check a given character is an upperca...