Question-:To convert lowercase to uppercase using bit manipulation
Code-:#include<bits/stdc++.h>
using namespace std;
#define ll long long int
cs(char n)
{
return (char(n&(~(1<<6))));
}
int main(){
char n;cin>>n;
cout<<cs(n);
return 0;
}
anyone?
#include<bits/stdc++.h>
using namespace std;
const int x = 32;
char *low_to_upr(char *a){
for (int i=0; a[i]!=’\0’; i++) a[i] &= ~x;
return a;
}
int main(){
char str[100];
cin>>str;
cout<<low_to_upr(str)<<endl;
}
toggle case using Xor
#include<bits/stdc++.h>
using namespace std;
string toggle(string s){
for(int i=0;i<s.size();i++){
s[i] ^= 32;
}
return s;
}
int main(){
string s;
cin>>s;
cout<<toggle(s);
}
thanks