Write a program to convert a string from upper case to lower case and vice versa.
Input
#include <stdio.h>
#include <string.h>
int main() {
char s[100];
int i;
printf("\nEnter a string : ");
fgets(s,100,stdin);
for (i = 0; s[i]!='\0'; i++) {
if(s[i] >= 'A' && s[i] <= 'Z') {
s[i] = s[i] + 32;
}
}
printf("\nString in Lower Case = %s\n", s);
return 0;
}
Output
Enter a string : DIPSHIKHA
String in Lower Case = dipshikha
Input
#include <stdio.h>
#include <string.h>
int main() {
char s[100];
int i;
printf("\nEnter a string : ");
fgets(s,100,stdin);
for (i = 0; s[i]!='\0'; i++) {
if(s[i] >= 'A' && s[i] <= 'Z') {
s[i] = s[i] + 32;
}
}
printf("\nString in Lower Case = %s\n", s);
return 0;
}
Output
Enter a string : DIPSHIKHA
String in Lower Case = dipshikha
No comments:
Post a Comment