Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

MATLAB Program to find the initials of a name



Program to find the initials of a name.
Main idea:
Take the first letter of all words & print in capital letters

Example:
Input  : prabhat kumar singh
Output : P K S
Input: Satadru Mukherjee
Output: S M

Code:

x=input('Enter th name:');

q=double(x);
Y=[];
Y(1)=q(1);
Y(2)=32;
k=3;
for i=1:length(q)
    if(q(i)==32)
        Y(k)=q(i+1);
        k=k+1;
        Y(k)=32;
        k=k+1;
    end
end
for i=1:length(Y)
    if(Y(i)>=97 && Y(i)<=122)
        Y(i)=Y(i)-32;
    end
end
a=char(Y)

Explanation:



Output:


Prerequisite  Video:



No comments

Popular Posts

Followers