i want a solution. is it possible that if i press 1 and get the upper case of the string and when i press 2, then got the lower case if the string via using the switch condition or something else.i just started coding and new to this field.
i tried to do this thing with function, but maybe due to lake of knowledge, id did nit get the result.
int main()
char str[100];
int i;
// printf("Enter the string: \n");
// gets(s);
switch (case)
int main()
{
int case;
printf("Enter the string: \n");
scanf("%d", &case);
gets(str);
switch(case)
{
case 1:
for(i = 0; str[i] != '\0' ; i++)
if(str[i] >= 'a' && s[i] <= 'z')
str[i] = str[i] - 32;
printf("\n The string's upper case = %s", str);
break;
case 2:
for(i = 0; str[i] != '\0' ; i++)
if(str[i] >= 'A' && str[i] <= 'Z')
str[i] = str[i] + 32;
printf("\n The string's lower case = %s", str);
break;
default: printf("Choice other than 1, 2 and 3");
break;
}
return 0;
}
m expecting when i press 1 then get the upper case and when i press 2 i get lower case in string.
1
hello world
2
HELLO WORLD
i want to do it with the switch.