Computer Science, asked by adriano2460, 1 year ago

Write a program to determine whether the entered character is in uppercase or lowercase, or is an invalid character.

Answers

Answered by rakeshchennupati143
2

Language-used:

Python

Program

char = input("Enter a character")

if ord(char) >= 65 or ord(char) <= 90:

   print(char," is upper-case")

elif ord(char) >= 97 or ord(char) <= 112:

   print(char," is lower-case")

else:

   print(char," is invalid character")

# 65 - 90(CAPS)

# 97 - 112 (SMALLS)

Output:

Enter a character

Z

90

Explanation

  1. first i turned taken character into its ASCII formate and checked from 65 to 90 because upper-case English alphabets starts at 65
  2. if true i will print it as upper case
  3. else i will check again from 97 to 112 because the lower case English alphabets starts at 97 and ends at 112
  4. if true then i will print it as lower-case
  5. else if the both the condition are false then i will print it as invalid character

------Hope this help   :)

Answered by sougatap57
1

Answer:

The language used here:-

1.c

2.c++

C program:- To determine whether the entered character is uppercase or lowercase or is an invalid character

#include<stdio.h>

int main()

{

char ch;

printf("enter the character");

scanf("%c",&ch);

if(ch>='a' &&ch<='z')

{

printf("it is lowercase letters);

}

else if(ch>='A' && ch<='Z')

{

printf("it is uppercase letters);

}

else{

printf("it is invalid character");

}

return 0;

}

Output

enter the character a

it is lowercase letters

c++ program:-

#include <iostream>

using namespace std;

int main()

{

 char ch;

 cout<<"enter the character";

 cin>>ch;

 if(ch>='a'&&ch<='z')

 {

     cout<<"it is lowercase";

 }

 else if(ch>='A'&&ch<='Z')

 {

     cout<<"it is uppercase";

 }

 else

 {

     cout<<"it is an invalid character";

 }

  return 0;

}

Output:-

enter the character A

it is uppercase

Similar questions