Computer Science, asked by minibindra2016, 8 months ago

Write a program to input a character using scanner class . If it is in an English alphabet in lowercase then convert it to its upper class and print it otherwise give an error message "Conversion not required"​

Answers

Answered by indujajeevanaschool
0

Answer:

If character in a index is in lower case, then subtract 32 to convert it in upper case, else add 32 to convert it in lower case. Print the final string.

Input: ch = 'A' Output: A is an UpperCase character Input: ch = 'a' ... try your approach on {IDE} first, before moving on to the solution. ... Capital letter Alphabets (A-Z) lie in the range 65-91 of the ASCII value ... ch << " is an LowerCase character\n" ;. else. cout<< ch << " is not an ... Most popular in C Programs.

Answered by growingup
0

Explanation:

Approach: The key to solve this problem lies in the ASCII value of a character. It is the most simple way to find out about a character. This problem is solved with the help of following detail:

Capital letter Alphabets (A-Z) lie in the range 65-91 of the ASCII value

Small letter Alphabets (a-z) lie in the range 97-122 of the ASCII value

Any other ASCII value is a non-alphabetic character.

Implementation:

// C++ implementation of the above approach

#include<bits/stdc++.h>

using namespace std;

void check(char ch)

{

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

cout<< ch << " is an UpperCase character\n";

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

cout<< ch << " is an LowerCase character\n";

else

cout<< ch << " is not an aplhabetic character\n";

}

// Driver Code

int main()

{

char ch;

// Get the character

ch = 'A';

// Check the character

check(ch);

// Get the character

ch = 'a';

// Check the character

check(ch);

// Get the character

ch = '0';

// Check the character

check(ch);

return 0;

}

// This code is contributed by Code_M

Similar questions