Write a C program to convert uppercase to lowercase and vice-versa.
int main() {
char str[100];
int i = 0;
/* get the input from the user */
printf("Enter your input:");
fgets(str, 100, stdin);
while (str[i] != '\n') {
/* convert upper case to lower case */
if (str[i] >= 65 && str[i] <= 90)
str[i] = str[i] + 32;
/* convert lowercase to upper case */
else if (str[i] >= 97 && str[i] <= 122)
str[i] = str[i] - 32;
i++;
}
printf("Result: %s", str);
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Enter your input:see-programming.blogspot.com
Result: SEE-PROGRAMMING.BLOGSPOT.COM
Enter your input:see-programming.blogspot.com
Result: SEE-PROGRAMMING.BLOGSPOT.COM
No comments:
Post a Comment