LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 02-21-2008, 09:53 PM   #1
ssaslam
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Rep: Reputation: 0
Generate random numbers in C program


Hi, im a newbie here...
Can any one show me a sample program for generating real number like 1,4,7,10,13and 16
i need it in c program i'm trying this but it just produces a real number... i need it in a sequence... so please help!!!!!!!
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)

{
int range;

srand (time(NULL));
range= (3-3)+1;

printf (" %d ", rand() %range +10);
printf (" %d ", rand() %range +10);
printf (" %d ", rand() %range +10);
printf (" %d ", rand() %range +10);
printf (" %d ", rand() %range +10);
printf (" %d\n ", rand() %range +10);
system ("PAUSE");
return 0;
}
 
Old 02-21-2008, 11:39 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


http://www.linuxquestions.org/questi...rogram-622895/
 
  


Closed Thread



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
Generate random numbers in C program ssaslam Linux - Newbie 5 10-23-2008 08:28 PM
using /dev/random to output random numbers on a text file guguma Programming 4 04-02-2007 01:42 PM
Generate random number with C++ TruongAn Programming 5 11-09-2005 12:01 AM
Creating random numbers from shell with /dev/random khermans Linux - General 1 07-13-2004 12:12 PM
Generating random numbers for C program J-Stew Programming 14 02-06-2004 04:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:56 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration