473,378 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Syntax issue

Hey I have a CODE that some 1 wrote however he use this line

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

i was wondring in what situation i will have to use it?
and does it good for?

Second thing Can some 1 explain me the way to use the MAX_RAND while
using rand() I dont understand what does the MAX_RAND do

10x in advance

Aug 24 '06 #1
12 1590
Chief wrote:
Hey I have a CODE that some 1 wrote however he use this line

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

i was wondring in what situation i will have to use it?
and does it good for?

Second thing Can some 1 explain me the way to use the MAX_RAND while
using rand() I dont understand what does the MAX_RAND do

10x in advance
dude 4 yr 1st ques its the comma ope8r dont have 2 use it if
u dont want 2 handy some timz anyway c book has all u need 2
no 4 sure 2nd ques no such animal hope this helps ciao babe

--
Eric Sosman
es*****@acm-dot-org.invalid
Aug 25 '06 #2

Eric Sosman wrote:
Chief wrote:
Hey I have a CODE that some 1 wrote however he use this line

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

i was wondring in what situation i will have to use it?
and does it good for?

Second thing Can some 1 explain me the way to use the MAX_RAND while
using rand() I dont understand what does the MAX_RAND do

10x in advance

dude 4 yr 1st ques its the comma ope8r dont have 2 use it if
u dont want 2 handy some timz anyway c book has all u need 2
no 4 sure 2nd ques no such animal hope this helps ciao babe
Medic! MEDIC! Even Eric's caught it now. Nobody's safe. Condoms on
fingers everyone.

Aug 25 '06 #3
Chief posted:
Hey I have a CODE

Culminary Orthogonal Device Ensembles are off-topic here.

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

In C++, maybe. In C, assignment to a variable cannot result in output.

i was wondring in what situation i will have to use it?

<OFF-TOPIC>

When CODE's enter Relax Mode, they tend to over-iterate through arrays --
the only way to normalise the indexing is by using the comma operator in
conjuction with multiple assignments.

</OFF-TOPIC>

and does it good for?

It works quite well (on modern CPU's). Don't try it on a 486.

Second thing Can some 1 explain me the way to use the MAX_RAND while
using rand() I dont understand what does the MAX_RAND do

Yes, indeed:

int max = (MAX_RAND, rand());

(See how I have normalised the over-iteration by using the comma operator
in conjunction with mutiple assignments?)

10x in advance

Whoa whoa whoa, don't get ahead of yourself! If the algorithm which
initialises the CODE is run ten times in advance, the over-iteration will
be far too erratic to correct. Any attempt to normalise the indexing at
that point will result in hard-disk over-burn -- so let's hope you keep
everything backed up.

--

Frederick Gotham
Aug 25 '06 #4
On Fri, 25 Aug 2006 01:41:15 GMT, Frederick Gotham
<fg*******@SPAM.comwrote:
>Chief posted:
>Hey I have a CODE


Culminary Orthogonal Device Ensembles are off-topic here.

>x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )


In C++, maybe. In C, assignment to a variable cannot result in output.
If that were true, then code of the form
if ((ptr = malloc(10)) == NULL)
could never work.

The result of evaluating the assignment operator is the value that is
assigned to the left operand. The statement evaluates as
assign 4 to y
discard result
assign 6 to z
assign result (in this case 6) to x

Remove del for email
Aug 25 '06 #5
Eric Sosman wrote:
Chief wrote:
Hey I have a CODE that some 1 wrote however he use this line

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

i was wondring in what situation i will have to use it?
and does it good for?

Second thing Can some 1 explain me the way to use the MAX_RAND while
using rand() I dont understand what does the MAX_RAND do

10x in advance

dude 4 yr 1st ques its the comma ope8r dont have 2 use it if
u dont want 2 handy some timz anyway c book has all u need 2
no 4 sure 2nd ques no such animal hope this helps ciao babe
This gets bookmarked ;-)

Aug 25 '06 #6
Barry Schwarz wrote:
On Fri, 25 Aug 2006 01:41:15 GMT, Frederick Gotham
<fg*******@SPAM.comwrote:
Chief posted:
Hey I have a CODE

Culminary Orthogonal Device Ensembles are off-topic here.

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

In C++, maybe. In C, assignment to a variable cannot result in output.

If that were true, then code of the form
if ((ptr = malloc(10)) == NULL)
could never work.

The result of evaluating the assignment operator is the value that is
assigned to the left operand. The statement evaluates as
assign 4 to y
discard result
assign 6 to z
assign result (in this case 6) to x
What Mr Gotham said was that variable assignment cannot result in
*output*, in reply to the OP's statement that the assignment resulted
in a line of output.

Robert Gamble

Aug 25 '06 #7
Barry Schwarz posted:
>>In C++, maybe. In C, assignment to a variable cannot result in output.

If that were true, then code of the form
if ((ptr = malloc(10)) == NULL)
could never work.

You're correct. I meant to say I was referring to assignments involving
simple object names:

a = b;

In C++, this could result in output (depending on whether there's a user-
defined assignment operator for the type "a" is).

In C, it can't do anything more than change the value of "a".

--

Frederick Gotham
Aug 25 '06 #8
Frederick Gotham wrote:
Barry Schwarz posted:
>In C++, maybe. In C, assignment to a variable cannot result in output.
If that were true, then code of the form
if ((ptr = malloc(10)) == NULL)
could never work.


You're correct. I meant to say I was referring to assignments involving
simple object names:

a = b;

In C++, this could result in output (depending on whether there's a user-
defined assignment operator for the type "a" is).

In C, it can't do anything more than change the value of "a".
No legal assignment can result in the printing of output, not just
those involving simple object names.

Robert Gamble

Aug 25 '06 #9
Robert Gamble posted:
No legal assignment can result in the printing of output, not just
those involving simple object names.

#include <stdio.h>

int main(void)
{
int a,b,c,d,e,f,g;

a = puts("Hello!");
b = puts("Hello!");
c = puts("Hello!");
d = puts("Hello!");
e = puts("Hello!");
f = puts("Hello!");
g = puts("Hello!");

return 0;
}

--

Frederick Gotham
Aug 25 '06 #10

Frederick Gotham wrote:
Robert Gamble posted:
No legal assignment can result in the printing of output, not just
those involving simple object names.


#include <stdio.h>

int main(void)
{
int a,b,c,d,e,f,g;

a = puts("Hello!");
b = puts("Hello!");
c = puts("Hello!");
d = puts("Hello!");
e = puts("Hello!");
f = puts("Hello!");
g = puts("Hello!");

return 0;
}
Perhaps you don't realize this, but it is the call to the puts function
that results in the output, not the assignment of its return value.

Robert Gamble

Aug 25 '06 #11
In article <11**********************@p79g2000cwp.googlegroups .com>,
Robert Gamble <rg*******@gmail.comwrote:
>No legal assignment can result in the printing of output, not just
those involving simple object names.
char *IOP = (char *) 0xffff01e4UL;
*IOP = 'h'; *IOP = 'i'; *IOP = '\n';

If address 0xffff01e4 happens to be an IO port, then you could
get the printing of output.

These assignments *are* legal, and converting an integral type
into a pointer is explicitly allowed in the C standard. The result
of all of this is implementation defined, sure, but violates no
constraints.
--
Prototypes are supertypes of their clones. -- maplesoft
Aug 25 '06 #12
On 24 Aug 2006 15:38:51 -0700, "Chief" <bl******@gmail.comwrote:
>Hey I have a CODE that some 1 wrote however he use this line

x= (y=4,z=6);

( by the way the output of this line is x=6 , y=4 , z=6 )

i was wondring in what situation i will have to use it?
and does it good for?
I can't think of any good situation in which you will have to use it.
It's not good for anything that I can think of.

If you worked for me and I came across code like this of yours in a
review, I'd tell you that you have two options:

Either change the code to something like this:

int x = 6;
int y = 4;
int z = 6;

or get up out of your chair and walk down the hall to the HR's office,
where you'll be picking up your termination papers. Your (his) code is
indeed Standard C code, but it's not appropriate Standard C code, at
least for the real world.
>Second thing Can some 1 explain me the way to use the MAX_RAND while
using rand() I dont understand what does the MAX_RAND do
It's RAND_MAX, not MAX_RAND. There are some C FAQs that deal with this
(search for RAND_MAX at this URL).

http://www.faqs.org/faqs/C-faq/faq/
>10x in advance
When I see something like "10x", I think of flyfishing tippet. And
"10x" is very, very fine--and possibly non-existant--flyfishing
tippet. I've never heard of "10x" flyfishing tippet. But that doesn't
mean that you don't fish with "10x" flyfishing tippet--perhaps you do.

--
jay
Aug 31 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
75
by: David MacQuigg | last post by:
Seems like we need a simple way to extend Python syntax that doesn't break existing syntax or clash with any other syntax in Python, is easy to type, easy to read, and is clearly distinct from the...
5
by: Drifter | last post by:
The quote below is part of the information i want to save to a MS Access database - or update, as the case may be. The original database was built a long time ago, and looking at the code for...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
8
by: BobTheDatabaseBoy | last post by:
the following syntax is accepted: alter table DB2ADMIN.APPTS add constraint appts_status check (lob_appt_status in ( case when state_code = 'VA' then 'P' -- , 'I' else 'X'
15
by: computerider | last post by:
I have this code which works fine and will open the form to the correct record but it produces a "Type mismatch" msgbox on opening the record... the stLinkCriteria consists of two values one of...
3
by: BD | last post by:
Hi, folks. Sorry about this - I have been R'ing all TFM's I can find, but am just getting more frustrated. Background: db2 UDB 8.1 on Windows. I'm quite new to db2, but have several...
7
by: sumanta123 | last post by:
Dear Sir when i am getting the value from properties file the the path showing http://127.0.0.1:81/help/Subject of Issue.txt which is right. But in jsp in try block when pass SubjectofIssue path...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.