#include <iostream> using namespace std; int main(){ char letter,letter1; cin>>letter; char change_to_lower(letter); char change_to_upper(letter); char swap(letter); return 0; } char change_to_lower(char a){ if(a=='a'&& a<='z'){ char b= toupper(a); return b; } } char change_to_upper(char a){ if(a=='a'&& a<='z'){ char b = tolower(a); return b; } } char swap(char a){ char letter1,letter2; a=change_to_lower(letter1); char b=change_to_upper(letter1); char temp = a; a=b; b=temp; cout<< a<<" "<< b<<endl; return b; }
do mean convert uppercase characters lowercase characters , lowercase letters uppercase letters, in string?
void swapuplo(char *s) { size_t i; (i = 0; s[i]; ++i) if (isupper(s[i])) s[i] = tolower(s[i]); else if (islower(s[i])) s[i] = toupper(s[i]); }
this calling routine
int main() { char buf[] = "hello world"; swapuplo(buf); printf("%s\n", buf); getchar(); return 0; }
output:
hello world
be sure include <ctype.h>
, contains declarations character testing functions.
Comments
Post a Comment