Convert characters of a string to opposite case in MATLAB
Write a MATLAB code to convert characters of a string to opposite case
example:
Input: Satadru Mukherjee
Output: sATADRU mUKHERJEE
Code:
example:
Input: Satadru Mukherjee
Output: sATADRU mUKHERJEE
Code:
x=input('Enter the name:');
q=double(x);
for i=1:length(q)
if(q(i)>=65 && q(i)<=90)
q(i)=q(i)+32;
elseif(q(i)>=97 && q(i)<=122)
q(i)=q(i)-32;
end
end
a=char(q)
Output:
Explanation:
No comments