one line c expression to print 1 -100 num

B

bobby

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
 
B

Ben Pfaff

bobby said:
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.
 
S

santosh

bobby said:
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.
 
A

Army1987

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;
 
D

Darko

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 :)
 
B

bobby

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
 
K

Keith Thompson

bobby said:
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.
 
C

CBFalconer

bobby said:
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.
 
D

Darko

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) (e-mail address removed) <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) ;-)
 
R

Richard Heathfield

Darko said:
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.
 
D

Darko

Darko said:





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.
 
C

Chris Dollin

Richard said:
Darko said:


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top