-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCase.c
More file actions
22 lines (19 loc) · 1022 Bytes
/
Copy pathCase.c
File metadata and controls
22 lines (19 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Problem Statement: Write a C program to determine whether a given character is uppercase or lowercase.
// The program should take a single character as input and use its ASCII value to identify its case.
#include<stdio.h>
int main(){
char ch;
scanf("%c",&ch);
int n = (int)ch;
if(n<97){
printf("Its uppercase");
} else {
printf("Its lowercase");
}
}
// Working of the Code:
// The program starts by declaring a character variable `ch` to store the user input and an integer variable `n` to store the ASCII value of `ch`.
// The user inputs a single character using `scanf`. The character's ASCII value is then obtained by casting it to an integer.
// If the ASCII value (`n`) is less than 97, the character is uppercase (ASCII values for 'A' to 'Z' range from 65 to 90).
// Otherwise, the character is lowercase (ASCII values for 'a' to 'z' range from 97 to 122).
// The program uses `printf` to display whether the character is uppercase or lowercase.