-1

Probably really easy, but i´m a newbie in coding. So I want to write a code which asks the user to define the variable n. After that the program should draw a polygon with n corners. Any examples?

1 Answers1

0

Here’s some pseudocode that might help you (I don’t know what language you are specifying):

1) Ask the user for the number of sides, and store it to variable s. 2) For each side, increment the variable n, and run the next line of code. 3) Draw a line between (cos(n*360/s), sin(n*360/s)) and (cos((n-1)*360/s), sin((n-1)*360/s)

You will have drawn a regular polygon with “s” sides and angles!

iPhoenix
  • 719
  • 7
  • 20