Computer Programming

User Define Function

  1. chinxan87
  2. Guy Lecky-Thompson

This archived discussion is "read only" due to the absence of an active Feature Writer/moderator for this topic.



Top
1.   Sep 25, 2006 5:09 AM

» chinxan87 - how to run a program?


How to run a program using,user defined function,if to create;a void subroutine that would draw a box on the entire screen. The character to used a border of the box depends on the user's input. The program uses a function which is void?

-- posted by chinxan87

Permalink Print Discussion Print Discussion Email Discussion Email Discussion Suite101: User Define Function How to subscribe to feeds

Top
2.   Sep 26, 2006 1:17 AM

» Guy Lecky-Thompson - how to run a program?

In response to how to run a program? posted by chinxan87:
Hi,
I am going to assume that you want a language independent answer, although I will probably implement this in C as an article for beginners as it illustrates several core programming concepts.

Firstly, you need to decide how you are going to get the input from the user. The choices are : from the command line, or as input during the execution.

Then, you must construct a counted loop in which each cell to be drawn is visited by a step in the loop.

There are two ways to do this : either construct two loops, one for the vertical lines, and one for the horizontal lines (2 of each), or test each cell to see if it is on the border in a nested loop, and write to it if it is.

Clue : the first approach is easy, the second is harder, more computationally expensive, but has some benefits, I'm sure.

In pseudocode, you'll end up with something like:

FOR X = 0 TO SCREEN_WIDTH
PRINT USER_CHARACTER AT POS X, 0
PRINT USER_CHARACTER AT POS X, SCREEN_DEPTH
END FOR

FOR Y = 0 TO SCREEN_DEPTH
PRINT USER_CHARACTER AT POS 0, Y
PRINT USER_CHARACTER AT POS SCREEN_WIDTH, Y
END FOR

For a detailed discussion on loops in C, click here.

For a full C programming tutorial, covering every aspect of this language, click here.


Hope this helps, and look out for the fully worked out tutorial!

Suite101
Guy Lecky-Thompson
Contributing Writer for Suite101

Permalink Print Discussion Print Discussion Email Discussion Email Discussion Suite101: User Define Function How to subscribe to feeds

This archived discussion is "read only" due to the absence of an active Feature Writer/moderator for this topic.

Please follow the guidelines set forth in the Suite101 Posting Etiquette when adding to the discussion.


about us limelight blog writing jobs careers press room site map terms & conditions privacy policy suite101.de