Why this code show segmentation fault?

your while loop is ending at line no 21 but it should end at 38

also you are printing in clockwise but question is for anticlock wise

also take care of output format

you can see changes here

Modified Code

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course