Hi,
Can someone give the standard function which can create positive
integer value in C?
Thanks,
Deepak 63 5644
deepak said:
Hi,
Can someone give the standard function which can create positive
integer value in C?
What does your textbook say about the generation of random numbers?
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
deepak wrote:
Hi,
Can someone give the standard function which can create positive
integer value in C?
Thanks,
Deepak
Look-up rand.
On Dec 18, 4:27 am, santosh <santosh....@gm ail.comwrote:
deepak wrote:
Hi,
Can someone give the standard function which can create positive
integer value in C?
Thanks,
Deepak
Look-up rand.
You may want to man for rand series entirely; e.g. you may want to use
srand, and seed it with something like your system time to generate
random sequences, etc.
:D
deepak wrote:
Hi,
Can someone give the standard function which can create positive
integer value in C?
There is no standard C function that creates numbers out of nothing.
If you are rather looking for a pseudo-random generator, see the C FAQ.
--
Tor <bw****@wvtqvm. vw | tr i-za-h a-z>
Jack Klein <ja*******@spam cop.netwrites:
On Tue, 18 Dec 2007 00:43:10 -0800 (PST), deepak
<de*********@gm ail.comwrote in comp.lang.c:
>Can someone give the standard function which can create positive integer value in C?
Other's have talked about "rand()", but I don't see anything in your
post that requires it.
[...]
The subject was "Positive random number". That information should
have been in the body of the original post.
--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On Tue, 18 Dec 2007 20:30:18 -0600, Jack Klein <ja*******@spam cop.net>
wrote:
>On Tue, 18 Dec 2007 00:43:10 -0800 (PST), deepak <de*********@g mail.comwrote in comp.lang.c:
>Hi,
Can someone give the standard function which can create positive integer value in C?
Other's have talked about "rand()", but I don't see anything in your post that requires it. Here's a function guaranteed to meet the requirement you asked for in the body of your message:
int create_positive _integer_value_ in_C(void) {
return 42; }
Definitely *not* guaranteed.
In C99, section 5.2.4.1 Translation limits:
"The implementation shall be able to translate and execute at least
one program that contains at least one instance of every one of the
following limits:
....
31 significant initial characters in an external identifier..."
The identifier "create_positiv e_integer_value _in_C" is an external
identifier with 34 characters, and thus exceeds the minimum number of
characters *guaranteed* to be accepted by the standard. In C90, the
minimum was a paltry six characters.
Now, an identifier such as "create_positiv e_int_value_in_ C" (30
characters) is acceptable in C99, but not necessarily in C90, though
arguably it is acceptable in most--if not all--C90 compilers in the
real world (for that matter, so is
"create_positiv e_integer_value _in_C" :^)
--
jay
jaysome wrote:
On Tue, 18 Dec 2007 20:30:18 -0600, Jack Klein <ja*******@spam cop.net>
wrote:
>>On Tue, 18 Dec 2007 00:43:10 -0800 (PST), deepak <de*********@ gmail.comwrote in comp.lang.c:
>>Hi,
Can someone give the standard function which can create positive integer value in C?
Other's have talked about "rand()", but I don't see anything in your post that requires it. Here's a function guaranteed to meet the requirement you asked for in the body of your message:
int create_positive _integer_value_ in_C(void) { return 42; }
Definitely *not* guaranteed.
In C99, section 5.2.4.1 Translation limits:
"The implementation shall be able to translate and execute at least
one program that contains at least one instance of every one of the
following limits:
...
31 significant initial characters in an external identifier..."
The identifier "create_positiv e_integer_value _in_C" is an external
identifier with 34 characters, and thus exceeds the minimum number of
characters *guaranteed* to be accepted by the standard. In C90, the
minimum was a paltry six characters.
What part of "31 significant initial characters" did you not understand.
Jack's function name will only cause problems if he happened to have
defined another identifier with the same sequence of 31 initial
characters.
"santosh" <sa*********@gm ail.comschrieb im Newsbeitrag
news:fk******** **@registered.m otzarella.org.. .
jaysome wrote:
>On Tue, 18 Dec 2007 20:30:18 -0600, Jack Klein <ja*******@spam cop.net> wrote:
>>>On Tue, 18 Dec 2007 00:43:10 -0800 (PST), deepak <de********* @gmail.comwrote in comp.lang.c:
Hi,
Can someone give the standard function which can create positive integer value in C?
Other's have talked about "rand()", but I don't see anything in your post that requires it. Here's a function guaranteed to meet the requiremen t you asked for in the body of your message:
int create_positive _integer_value_ in_C(void) { return 42; }
Definitely *not* guaranteed.
In C99, section 5.2.4.1 Translation limits:
"The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:
...
31 significant initial characters in an external identifier..."
The identifier "create_positiv e_integer_value _in_C" is an external identifier with 34 characters, and thus exceeds the minimum number of characters *guaranteed* to be accepted by the standard. In C90, the minimum was a paltry six characters.
What part of "31 significant initial characters" did you not understand.
Jack's function name will only cause problems if he happened to have
defined another identifier with the same sequence of 31 initial
characters.
What part of "Definitely *not* guaranteed" didn't you understand? 8-))
Bye, Jojo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Virus |
last post by:
Ok well what I am trying to do is have
1.) the background color to change randomly with 5 different colors.(change
on page load)
2,) 10 different quotes randomly fadeing in and out in random spots on the
webpage. with a delay timer on them, so they keep changing as the page is
open. Not random each time the page is loaded.
If anyone can help it would be greatly appreaciated, I have tried many of
|
by: Johnny Snead |
last post by:
Hey guys,
Need help with this random sort algorithm
private void cmdQuestion_Click(object sender, System.EventArgs e)
{
Random rnd = new Random(); //initialize rnd to new random object
System.Random iRnd = new System.Random();
string theNum = iRnd.Next(0,8).ToString();
lblAnswer.Text = iRnd.Next(0,8).ToString();
|
by: fatimahtaher |
last post by:
Hi,
I am supposed to create a program that generates a random number and then asks the user to guess the number (1-100). The program tells the user if he guessed too high or too low. If he guessed right, it asks the user is he/she wants to play again. If the answer is yes, it generates a random number and asks the user to guess the number again. The user can exit if he enters 0. I have created the following code so far but it does not work....
|
by: Peter Oliphant |
last post by:
I would like to be able to create a random number generator that produces
evenly distributed random numbers up to given number.
For example, I would like to pick a random number less than 100000, or
between 0 and 99999 (inclusive).
Further, the I want the range to be a variable. Concretely, I would like to
create the following method:
unsigned long Random( unsigned long num )
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |