SPIES BERDAFTAR

10 February 2015

c programming source code sharing #6 : Printing a hollow square using nested for

ASSALAMMUALAIKUM W.B.T. peeps !

hi hi hi. (greeting ni, "hai hai hai" bukan gelak hi hi hi)
so today i would like to share the next source code, of my homework this week, freshly from oven!
*baru siap buat daa*

sample question:
Read an integer(entered by user) and prints a hollow square. the number of '=' used to draw line of each sides of square.

example, user enter 5, so the output is
=====
=      =
=      =
=      =
=====
a 5x5 square with a hollow.(hollow-lubang)
(not-so-square looking here, but in .exe file you'll see it is more like a square!)

another sample output:


of course, it will only works with positive integers.
& for integer=1 & 2, you'll not see a hollow.

soooo here's the screenshot of my source code:

CLICK IMAGE TO ENLARGE

or, download the c-file here. (can edit&try compile yourself!)

my lecturer told us, usually for this kind of question, there would be more than 1 solution. so my fellas out there, if you have a simpler & more unique way, please share! sharing is caring yow! & for any questions, please, just ask me ok? :)

regards,

No comments:

Post a Comment

pecah kaca sebab koman,
lepas baca harap komen. :D