473,386 Members | 1,812 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,386 software developers and data experts.

one line c expression to print 1 -100 num

write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
int i=1;
int main()
{

/*your expression here*/

printf("%d",i);

return 0;
}
mail ans to me

Jul 10 '07 #1
29 3020
bobby <jc***********@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
Your instructor deserves public shaming for giving out such a
lousy assignment.
--
Ben Pfaff
http://benpfaff.org
Jul 10 '07 #2
bobby wrote:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
Consider recursion.

Jul 10 '07 #3
santosh <sa*********@gmail.comwrites:
>bobby wrote:
>write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
>Consider recursion.
Without conditional evaluation, how will the recursion terminate?

--
Chris.
Jul 10 '07 #4
On Mon, 09 Jul 2007 22:09:21 -0700, bobby wrote:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
int i=1;
int main()
{

/*your expression here*/
i = -99;
>
printf("%d",i);

return 0;
}
mail ans to me
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)

Jul 10 '07 #5
Chris McDonald said:
santosh <sa*********@gmail.comwrites:
>>bobby wrote:
>>write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
>>Consider recursion.

Without conditional evaluation, how will the recursion terminate?
And without jumps, how will it start?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 10 '07 #6
Army1987 <ar******@NOSPAM.itwrites:
On Mon, 09 Jul 2007 22:09:21 -0700, bobby wrote:
>write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
int i=1;
int main()
{

/*your expression here*/
i = -99;
Good one. Ha-ha
>
>>
printf("%d",i);

return 0;
}
mail ans to me
Best regards
Xu Weijiang
--
everything has its rules!
Jul 10 '07 #7
On Jul 10, 7:09 am, bobby <jchandraka...@gmail.comwrote:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve

int i=1;
int main()
{

/*your expression here*/
printf( "2, 3, 4, ...., 100);
printf("%d",i);

return 0;}

mail ans to me
All numbers are printed, from 1 to 100 :)

Jul 10 '07 #8
i++;
printf("%d\n",i);
if( i != 101 ) main( );

Jul 10 '07 #9
On Tue, 10 Jul 2007 05:27:48 -0700, @$|-|. DUBEY wrote:
i++;
printf("%d\n",i);
if( i != 101 ) main( );
Hadn't the OP better do his own homework?
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)

Jul 10 '07 #10
On Jul 10, 10:14 am, Ben Pfaff <b...@cs.stanford.eduwrote:
bobby <jchandraka...@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve

Your instructor deserves public shaming for giving out such a
lousy assignment.
--
Ben Pfaffhttp://benpfaff.org
hey take light it is not a lousy assignment just keep thinking u will
get incase when u r not able to solve this then i will give u hints
dont give up best of luck

Jul 11 '07 #11
bobby <jc***********@gmail.comwrites:
On Jul 10, 10:14 am, Ben Pfaff <b...@cs.stanford.eduwrote:
>bobby <jchandraka...@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve

Your instructor deserves public shaming for giving out such a
lousy assignment.
--
Ben Pfaffhttp://benpfaff.org

hey take light it is not a lousy assignment just keep thinking u will
get incase when u r not able to solve this then i will give u hints
dont give up best of luck
If you're going to post to this newsgroup (or any other newsgroup),
please make some attempt to use standard English. Capitalize the word
"I" and the first word of each sentence, use punctuation, and don't
use silly abbreviations like "u", "r" and "ur". Nobody's going to
complain too much about minor errors, but your writing is almost
illegible.

What does "1 -100 numbers" mean, anyway? If you mean 1, 2, 3, ...,
100, there are much clearer ways to say so. '1 -100' is -99.

If this is a homework assignment, you're cheating yourself by asking
us to do it for you.

Finally, we're not giving up because it's hard, we're just not
interested.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 11 '07 #12
On Jul 11, 6:57 am, Keith Thompson <k...@mib.orgwrote:
bobby <jchandraka...@gmail.comwrites:
On Jul 10, 10:14 am, Ben Pfaff <b...@cs.stanford.eduwrote:
bobby <jchandraka...@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
Your instructor deserves public shaming for giving out such a
lousy assignment.
--
Ben Pfaffhttp://benpfaff.org
hey take light it is not a lousy assignment just keep thinking u will
get incase when u r not able to solve this then i will give u hints
dont give up best of luck

If you're going to post to this newsgroup (or any other newsgroup),
please make some attempt to use standard English. Capitalize the word
"I" and the first word of each sentence, use punctuation, and don't
use silly abbreviations like "u", "r" and "ur". Nobody's going to
complain too much about minor errors, but your writing is almost
illegible.

What does "1 -100 numbers" mean, anyway? If you mean 1, 2, 3, ...,
100, there are much clearer ways to say so. '1 -100' is -99.

If this is a homework assignment, you're cheating yourself by asking
us to do it for you.

Finally, we're not giving up because it's hard, we're just not
interested.

--
Keith Thompson (The_Other_Keith) k...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Then this way (onda ovako :) ) :
printf( "1, 2, 3, ... , 99, " ), i+=99;
printf( "%d", i );

Stupid assignment, stupid solution (but correct) ;-)

Jul 11 '07 #13
Darko said:
>bobby <jchandraka...@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out
using control statements/structures,
jumps-conditional/unconditional.given the program dont modify
and solve
<snip>
>
Then this way (onda ovako :) ) :
printf( "1, 2, 3, ... , 99, " ), i+=99;
printf( "%d", i );

Stupid assignment, stupid solution (but correct) ;-)
Not quite correct, because it contains an unconditional jump to the
printf library function, and unconditional jumps are explicitly
forbidden by the problem text.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 11 '07 #14
On Jul 11, 1:44 pm, Richard Heathfield <r...@see.sig.invalidwrote:
Darko said:
bobby <jchandraka...@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out
using control statements/structures,
jumps-conditional/unconditional.given the program dont modify
and solve

<snip>
Then this way (onda ovako :) ) :
printf( "1, 2, 3, ... , 99, " ), i+=99;
printf( "%d", i );
Stupid assignment, stupid solution (but correct) ;-)

Not quite correct, because it contains an unconditional jump to the
printf library function, and unconditional jumps are explicitly
forbidden by the problem text.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
True, true... well, I don't know if cond/uncond jumps were meant to
refer to such situations, or just using if/goto. Anyway, I think
someone was screwing with this guy or he didn't completely understand
the task.

Jul 11 '07 #15
bobby wrote:
On Jul 10, 10:14 am, Ben Pfaff <b...@cs.stanford.eduwrote:
>bobby <jchandraka...@gmail.comwrites:
>>write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve

Your instructor deserves public shaming for giving out such a
lousy assignment.

hey take light it is not a lousy assignment just keep thinking u
will get incase when u r not able to solve this then i will give
u hints dont give up best of luck
Are you possibly trying to say something? It is not recognizable
in that mess of geek speek. Hints: 'you' is spelled 'you'. 'are'
is spelled 'are'. 'i' is spelled 'I'. "dont" is spelled "don't".
Use of punctuation is permitted in Usenet.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 11 '07 #16
Richard Heathfield wrote:
Darko said:
>>bobby <jchandraka...@gmail.comwrites:
write a online c expression to print 1 -100 numbers with out
using control statements/structures,
jumps-conditional/unconditional.given the program dont modify
and solve
<snip>
>>
Then this way (onda ovako :) ) :
printf( "1, 2, 3, ... , 99, " ), i+=99;
printf( "%d", i );

Stupid assignment, stupid solution (but correct) ;-)

Not quite correct, because it contains an unconditional jump to the
printf library function, and unconditional jumps are explicitly
forbidden by the problem text.
Not so. /Jumps/ are forbidden, but since printing /anything/ requires
a function call, function calls must be permitted (since Of Course
the assignment must not visibly Not Have a solution) and hence are
not jumps.

My solution: the one-line C expression is

printf( "17\n" )

since I choose to print one number (Clearly I can print one or
two or ... one hundred numbers) and I've nominated 17 (for obvious
reasons -- clc is Hell, right?) as my one number.

--
RIP Donald Michie 11 November 1923 - 7 July 2007

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Jul 11 '07 #17
CBFalconer wrote:
'you' is spelled 'you'.
'you' *are* spelled 'you'.
'i' is spelled 'I'.
'i' *am* spelled 'I'.

:):):):)

--
pete
Jul 11 '07 #18
pete said:
CBFalconer wrote:
>'you' is spelled 'you'.

'you' *are* spelled 'you'.
>'i' is spelled 'I'.

'i' *am* spelled 'I'.

:):):):)
Smileys apart, look up "use/mention distinction".

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 11 '07 #19
pete wrote, On 11/07/07 22:05:
CBFalconer wrote:
>'you' is spelled 'you'.

'you' *are* spelled 'you'.
>'i' is spelled 'I'.

'i' *am* spelled 'I'.
OK, so if I've got the right, 'you' are spelled 'I' and Chuck is spelled
'you'. So am I spelled Flash?
:):):):)
:-)
--
Flash Gordon
Jul 11 '07 #20
On Jul 10, 3:01 pm, Richard Heathfield <r...@see.sig.invalidwrote:
Chris McDonald said:
santosh <santosh....@gmail.comwrites:
>bobby wrote:
>write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
>Consider recursion.
Without conditional evaluation, how will the recursion terminate?

And without jumps, how will it start?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
expression is i=i<100?i++,main(),++i:1;

Jul 14 '07 #21
On Jul 10, 2:52 pm, Army1987 <army1...@NOSPAM.itwrote:
On Mon, 09 Jul 2007 22:09:21 -0700, bobby wrote:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
int i=1;
int main()
{
/*your expression here*/

i = -99;
printf("%d",i);
return 0;
}
mail ans to me

--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)
expression is i=i<100?i++,main(),++i:1;

Jul 14 '07 #22
On Jul 10, 4:03 pm, Darko <darko.maksimo...@gmail.comwrote:
On Jul 10, 7:09 am, bobby <jchandraka...@gmail.comwrote:write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
int i=1;
int main()
{
/*your expression here*/

printf( "2, 3, 4, ...., 100);
printf("%d",i);
return 0;}
mail ans to me

All numbers are printed, from 1 to 100 :)
expression is i=i<100?i++,main(),++i:1;

Jul 14 '07 #23
On Jul 10, 5:37 pm, Army1987 <army1...@NOSPAM.itwrote:
On Tue, 10 Jul 2007 05:27:48 -0700, @$|-|. DUBEY wrote:
i++;
printf("%d\n",i);
if( i != 101 ) main( );

Hadn't the OP better do his own homework?
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)
expression is i=i<100?i++,main(),++i:1;

Jul 14 '07 #24
bobby wrote:
>
On Jul 10, 5:37 pm, Army1987 <army1...@NOSPAM.itwrote:
On Tue, 10 Jul 2007 05:27:48 -0700, @$|-|. DUBEY wrote:
i++;
printf("%d\n",i);
if( i != 101 ) main( );
Hadn't the OP better do his own homework?
expression is i=i<100?i++,main(),++i:1;
That's wrong.
It should be
i = i < 100 ? i++, main(), i + 1 : 1;
instead.

(i = ++i) is undefined.

--
pete
Jul 14 '07 #25
bobby wrote:
On Jul 10, 3:01 pm, Richard Heathfield <r...@see.sig.invalidwrote:
>Chris McDonald said:
santosh <santosh....@gmail.comwrites:
>>bobby wrote:
>>write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
>>Consider recursion.
Without conditional evaluation, how will the recursion terminate?

And without jumps, how will it start?
expression is i=i<100?i++,main(),++i:1;
I see a control structure.

The original post says "with out using control statements/structures".
Since control /structures/ is explicitly stated as well as control
/statements/, conditional expressions (and && and ||) shouldn't be
allowed ...

--
exit(EXIT_FAILURE) Hedgehog
Meaning precedes definition.

Jul 15 '07 #26
On Sat, 14 Jul 2007 17:34:04 +0000, bobby wrote:
On Jul 10, 4:03 pm, Darko <darko.maksimo...@gmail.comwrote:
>On Jul 10, 7:09 am, bobby <jchandraka...@gmail.comwrote:write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
int i=1;
int main()
{
/*your expression here*/

printf( "2, 3, 4, ...., 100);
printf("%d",i);
return 0;}
mail ans to me

All numbers are printed, from 1 to 100 :)

expression is i=i<100?i++,main(),++i:1;
Elsethread you said that it mustn't call any function.
That expression calls main(), so according to your specifications
it is wrong.

--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)

Jul 15 '07 #27
>>>>"b" == bobby <jc***********@gmail.comwrites:

bOn Jul 10, 4:03 pm, Darko <darko.maksimo...@gmail.comwrote:
>On Jul 10, 7:09 am, bobby <jchandraka...@gmail.comwrote:
>>write a online c expression to print 1 -100 numbers with out
using control statements/structures,
jumps-conditional/unconditional.
bexpression is i=i<100?i++,main(),++i:1;

Except that the ternary operator (?:) is a control structure, and this
sort of recursion involves a conditional jump.

Your professor is insufficiently precise with his terms.

Charlton
--
Charlton Wilbur
cw*****@chromatico.net
Jul 15 '07 #28
In article <11**********************@m37g2000prh.googlegroups .comsantosh <sa*********@gmail.comwrites:
bobby wrote:
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve

Consider recursion.
Consider the comma operator.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Jul 17 '07 #29
Dik T. Winter wrote:
In article <11**********************@m37g2000prh.googlegroups .comsantosh <sa*********@gmail.comwrites:
bobby wrote:
>
write a online c expression to print 1 -100 numbers with out using
control statements/structures, jumps-conditional/unconditional.given
the program dont modify and solve
>
Consider recursion.

Consider the comma operator.
I hope the resulting statement will fit within a single logical source
line. Or does the OP mean a single physical line when he wants an "one
line" expression?

Jul 17 '07 #30

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

Similar topics

11
by: Russell Wallace | last post by:
Hi all, Python lets you continue a single logical line across more than one physical line, either by putting a \ at the end or letting it happen automatically with an incomplete infix operator....
0
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # David Eppstein of the Geometry Junkyard fame gave this elegant # version for returing all possible pairs from a range of n numbers. def combo2(n): return...
8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
5
by: hue | last post by:
I am trying to parse command line options using getopt module. I have written the following Code import string import getopt def usage(): print '''haarp_make.py -- uses getopt to...
14
by: Xah Lee | last post by:
is there a way to condense the following loop into one line? # -*- coding: utf-8 -*- # python import re, os.path imgPaths= # change the image path to the full sized image, if it exists
43
by: Roger L. Cauvin | last post by:
Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the letters 'a' and 'b' any number of times, e.g. "xyz123aaabbaabbbbababbbbaaabb" I'm...
23
by: Kaz Kylheku | last post by:
I've been reading the recent cross-posted flamewar, and read Guido's article where he posits that embedding multi-line lambdas in expressions is an unsolvable puzzle. So for the last 15 minutes...
5
by: Avi Kak | last post by:
Folks, Does regular expression processing in Python allow for executable code to be embedded inside a regular expression? For example, in Perl the following two statements $regex =...
5
by: Gigs_ | last post by:
Can someone explain me bitwise expression? few examples for every expression will be nice x << y Left shift x >y Right shift x & y Bitwise AND x | y Bitwise OR x ^ y Bitwise XOR (exclusive...
1
by: Ruth413 | last post by:
Hello - I am getting the these errors in my sql 2005 generated script. I am stuck with first error. Please help.... Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '('. Msg 319,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
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...

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.