LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-28-2004, 07:06 AM   #1
wolve
LQ Newbie
 
Registered: Jun 2004
Location: Budapest
Distribution: Debian Woody
Posts: 8

Rep: Reputation: 0
mechanical engineer tries to learn c



Hi! I'm a mechanical engineer student at BUTE. I'd really appriciate hints on how to make programs in c. Tutorials, quizzes, and more.
I want to make a program, which randomly generates 50 points in a Descartes-coordinate system, and connect them with lines, to form a VALID shape. the main goal is it's area (the shape's).
How genearte random numbers?
 
Old 11-28-2004, 09:30 AM   #2
Whatshisface
Member
 
Registered: Aug 2003
Location: Chesapeake Beach, MD
Distribution: Mandrake 9.2
Posts: 58

Rep: Reputation: 15
Any programming book will give you an example function. Do you have a compiler and are you familiar at all with the language? If you're running Linux, you should have installed a C compiler (cc) or probably a C++ compiler (gcc). Do a "whereis gcc" from the command line to see if you have it. If not, you will need to install it. Then it is a matter of editing your program and then from the command line, typing:
>gcc -o myprogram program.c <ENTER>
where program.c is your edited file and myprogram is the name of the program you're creating (the executable). In Windows these programs end with ".exe". In Linux it doesn't have to.
This will run the program through the preprocessor, compile and link standard libraries and create the executable module, "myprogram". Then you can just type:
>myprogram <ENTER>
and the program will run.
There are some built-in functions that come with a C compiler and rand() is one of them. I recommend "C Primer Plus" by The Waite Group if you already know a little about it. If you're really new, Look for something for newbies like "C By Example" by Greg Perry. Also, if yoiu're running Linux, get a Linux or Unix book to help with editing, compiling, linking, etc.
 
Old 11-28-2004, 04:07 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,536

Rep: Reputation: 148Reputation: 148
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 11-28-2004, 10:43 PM   #4
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Rep: Reputation: 121Reputation: 121
To generate random numbers there is the function:
random ()
in stdlib.h header file.

Type
Code:
man random
to find out more about the function.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pro engineer mjenkins Fedora 3 12-19-2005 10:15 AM
Engineer / Techie ? HadesThunder General 25 09-10-2004 09:10 PM
Network engineer, new to linux afriendlyface Linux - Networking 2 05-16-2004 02:47 PM
Trying to reverse engineer our network :) 8webguy8 Linux - Networking 12 03-17-2004 08:46 AM
How can you reverse engineer a small C program OrganicX Programming 1 01-30-2004 08:30 PM


All times are GMT -5. The time now is 04:49 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration