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

## Search This Blog

#Day29-Square from two Triangle

Task:
Print Square from two Triangle as shown below by taking user input for the number of lines or rows
Note: Show the difference between two triangles by using two special characters.

* * * * * &
* * * * & &
* * * & & &
* * & & & &

* & & & & &

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

Matlab code
function twotraingled_square(x)
k=0;
for i=x:-1:1
k=k+1;
for j=1:1:i

fprintf('\t');
fprintf('*');
end
for jj=1:1:k
fprintf('\t');
fprintf('&');
end

fprintf('\n');
end

Sample Input and Output
>> twotraingled_square(7)
* * * * * * * &
* * * * * * & &
* * * * * & & &
* * * * & & & &
* * * & & & & &
* * & & & & & &
* & & & & & & &
>> twotraingled_square(9)
* * * * * * * * * &
* * * * * * * * & &
* * * * * * * & & &
* * * * * * & & & &
* * * * * & & & & &
* * * * & & & & & &
* * * & & & & & & &
* * & & & & & & & &
* & & & & & & & & &

Click here for Video Description

Live Support: t.me/matlabirawen

MATLAB Book for the beginner: https://amzn.to/3fTfmTa