Computer Science, asked by aaravj65, 1 month ago

WAP to input a character and print it’s opposite case.
Example – If it is an upper case letter print it’s lower case and vice versa.

Answers

Answered by usjadhav2001
0

Answer:

follow me

make as brainliest ans

likes my All ans

ok

Explanation:

python:

str1="Great Power";

newStr = "";

for i in range(0, len(str1)):

#Checks for lower case character

if str1[i].islower():

#Convert it into upper case using upper () function

newStr += str1[i].upper();

#Checks for upper case character

elif str1[i].isupper():

#Convert it into lower case using lower () function

newStr += str1[i].lower();

else:

newStr += str1[i];

..................................................

C

include <stdio.h>

int main()

{

int i, len = 0;

char str[] = "Great Power";

//Calculating length of the array

len = sizeof(str)/sizeof(str[0]);

//Checks every character in the array

for(i = 0; i < len; i++){

//Checks whether a character is upper case character

if(isupper(str[i])){

//Convert that charcter to lower case

str[i] = tolower(str[i]);

}

//Checks whether a character is lower case character

else if(islower(str[i])){

//Convert that charcter to upper case

str[i] = toupper(str[i]);

}

}

printf("String after case conversion : %s", str);

return 0;

}

Similar questions
Math, 8 months ago