- #1

- 590

- 0

Code:

```
clc
clear
h=input('enter height of diamond :');
y=1;
while y<=h/2
for x=1:h-1
if x<=((h)/2-(y-1))
fprintf(1,'*\t');
end
if x>(h)/2-(y-1) & x<(h)/2+(y-1)
fprintf(1,'\t');
end
if x>=((h)/2+(y-1)) &x<=h-1
fprintf(1,'*\t');
end
end
y=y+1;
fprintf(1,'\n')
end
while y>h/2 &y<=h
for x=1:h-1
if x<=((h)/2-(h-y))
fprintf(1,'*\t');
end
if x>(h)/2-(h-y) & x<(h)/2+(h-y)
fprintf(1,'\t');
end
if x>=((h)/2+(h-y)) &x<=h-1
fprintf(1,'*\t');
end
end
y=y+1;
fprintf(1,'\n')
end
```

but for any even numbers i put in as my size, i get 2 extra asterixs on the corners, can anyone see how i chan get rid of them?