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

Search This Blog

#Day89#100DaysChallenge- Matlab Loops | Differentiate Odd and Even lines

#Day89-Differentiate Odd and Even lines

Task:

Write a code to Differentiate Odd and Even lines.Get user Input for number of rows
r-10;&-odd.*=even
&
*
&
*
&
*
&
*
&
*
 


Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.

Matlab code


function differentiateevenoddlines(r)

 for i=1:1:r

     if mod(i,2)==0

         fprintf('*');

     else

             fprintf('&');

     end

             fprintf('\n');

 end

Sample Input and Output


Click here for Video description.




No comments

Popular Posts