By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,071 Members | 1,244 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,071 IT Pros & Developers. It's quick & easy.

"Hello World" without semicolon with a difference

P: n/a
Hi,

Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.

So far,i figured this could be done by insertint the printf statement in main
as shown:

int main(int argc=printf("Hello world")
{
}
Note:This is not allowed in ANSI C,default arguments are more a C++ concept.

Even this doesnt work.It compiles & runs but doesnt print anything.

Is the solution to this question possible in c(or c++ for that matter)?
Nov 14 '05 #1
Share this Question
Share on Google+
33 Replies


P: n/a

I believe not unless you consider this a valid option:
#include <stdio.h>

#define WEE puts( "Hello World!" );

int main( int argc, char * argv[] ) {
WEE
}
...in fact to print on the screen you need an instruction.. and
in C every instruction has to be followed by a semi-colon.

Best regards.

ankursinha wrote:
Hi,

Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.

So far,i figured this could be done by insertint the printf statement in main
as shown:

int main(int argc=printf("Hello world")
{
}
Note:This is not allowed in ANSI C,default arguments are more a C++ concept.

Even this doesnt work.It compiles & runs but doesnt print anything.

Is the solution to this question possible in c(or c++ for that matter)?

--
Roberto Nunnari -software engineer-
mailto:ro**@nunnisoft.ch
http://www.nunnisoft.ch
Residenza Boschetto 12 tel/fax: +41-91-6046511
6935 Bosco Luganese """ mobile: +41-76-3208561
Switzerland (o o)
========================oOO==(_)==OOo============= ===========

Nov 14 '05 #2

P: n/a
ankursinha wrote:

Hi,

Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
Answer #1: No, because the C language has no concept of
a "screen."

Answer #2: Yes, as follows

??=include <stdio.h>
int main(void) {
puts ("Hello, world!");;
return 10??'012;;
??>

Observe that there are no single semi-colons.
The extra constraint here is that u r not allowed to use if,while,switch etc.
In that case, the problem is impossible. (Assumption: "etc"
includes the open parenthesis character '('.)
So far,i figured this could be done by insertint the printf statement in main
as shown:

int main(int argc=printf("Hello world")
{
}
Note:This is not allowed in ANSI C,default arguments are more a C++ concept.

Even this doesnt work.It compiles & runs but doesnt print anything.

Is the solution to this question possible in c(or c++ for that matter)?


DYOH. Or if you won't DYOH, at least RTFW.

--
Er*********@sun.com
Nov 14 '05 #3

P: n/a
ankursinha wrote:
Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.


This invokes undefined behaviour, because variable length array types
aren't compatible with normal array types, but it's the closest I
could get. It's C99, obviously.

#include <stdio.h>
int main(int argc, char *argv[static printf("Hello World\n"), 0])
{
}

There's also

#error "Hello World"

but I don't consider that a program.

Jeremy.
Nov 14 '05 #4

P: n/a
ankursinha wrote:
Hi,

Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.

So far,i figured this could be done by insertint the printf statement in main
as shown:

int main(int argc=printf("Hello world")
{
}
Note:This is not allowed in ANSI C,default arguments are more a C++ concept.

Even this doesnt work.It compiles & runs but doesnt print anything.

Is the solution to this question possible in c(or c++ for that matter)?


The endless September:
http://groups.google.com/groups?hl=e...Dcomp.lang.c.*

One should always consult the FAQ and search the newsgroups
before posting.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #5

P: n/a
> Is the solution to this question possible in c(or c++ for that matter)?

You could try:
int main(int argc, char **argv)
{
if (printf("Hello world!\n")) {}
}
Fits the bill?
Nov 14 '05 #6

P: n/a
Damn, didn't remember you couldn't use 'if'.

I'm afraid there isn't such a beast, then...
Nov 14 '05 #7

P: n/a
Jeremy Yallop wrote:

#include <stdio.h>
int main(int argc, char *argv[static printf("Hello World\n"), 0])
{
}

hehehe.. this is CLEVER!

Could you please explain why that works? I mean.. why that printf
statement gets executed? Has it something to do with the fact
that static variables get initialized at start time?

Best regards.
There's also

#error "Hello World"

but I don't consider that a program.

Jeremy.

--
Roberto Nunnari -software engineer-
mailto:ro**@nunnisoft.ch
http://www.nunnisoft.ch
Residenza Boschetto 12 tel/fax: +41-91-6046511
6935 Bosco Luganese """ mobile: +41-76-3208561
Switzerland (o o)
========================oOO==(_)==OOo============= ===========

Nov 14 '05 #8

P: n/a
In <40**********************@news.club-internet.fr> Guillaume <gr*******@NO-SPAMmail.com> writes:
Is the solution to this question possible in c(or c++ for that matter)?


You could try:
int main(int argc, char **argv)
{
if (printf("Hello world!\n")) {}
}
Fits the bill?


When did the following statement disappear from his post?

The extra constraint here is that u r not allowed to use
if,while,switch etc.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #9

P: n/a
In <95**************************@posting.google.com > an*********@hotmail.com (ankursinha) writes:
Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.


With this extra constraint, the solution involves cheating, one way or
another.

fangorn:~/tmp 470> cat test.c
#include <stdio.h>

int main()
{
puts("Hello World") _
}
fangorn:~/tmp 471> gcc -D_=\; test.c
fangorn:~/tmp 472> ./a.out
Hello World

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #10

P: n/a
an*********@hotmail.com (ankursinha) writes:
Is it possible to write a C program that prints "Hello World" on
screen without having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use
if,while,switch etc.


Why would you want to do that? Are you and Aniruddha taking the same
class? (Aniruddha has been posting to comp.lang.c.moderated asking
how to access command line arguments without using argc and argv, and
how to emulate sizeof without using sizeof.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #11

P: n/a
Keith Thompson <ks***@mib.org> scribbled the following:
an*********@hotmail.com (ankursinha) writes:
Is it possible to write a C program that prints "Hello World" on
screen without having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use
if,while,switch etc.
Why would you want to do that? Are you and Aniruddha taking the same
class? (Aniruddha has been posting to comp.lang.c.moderated asking
how to access command line arguments without using argc and argv, and
how to emulate sizeof without using sizeof.)


Accessing command line arguments without using argc and argv is easy.
Just name the parameters something else. =)

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"How come even in my fantasies everyone is a jerk?"
- Daria Morgendorfer
Nov 14 '05 #12

P: n/a
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Keith Thompson <ks***@mib.org> scribbled the following:
an*********@hotmail.com (ankursinha) writes:
Is it possible to write a C program that prints "Hello World" on
screen without having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use
if,while,switch etc.

Why would you want to do that? Are you and Aniruddha taking the same
class? (Aniruddha has been posting to comp.lang.c.moderated asking
how to access command line arguments without using argc and argv, and
how to emulate sizeof without using sizeof.)


Accessing command line arguments without using argc and argv is easy.
Just name the parameters something else. =)


That was one of the proposed solutions over in clcm, but the Aniruddha
said it didn't fit the specification (without explaining why using
argc and argv wasn't acceptable).

I suspect some instructor in India is assigning these silly problems
without making it sufficiently clear that asking Usenet to do your
homework for you is not acceptable. (I'm not picking on India; of the
two blatant examples of this I've seen, both posters have
Indian-sounding names, one posted from a *.in address, and the other
used a hotmail address.) That's just speculation; there may be no
connection between the two posters, but the questions have the same
feel to them.

There may be legitimate reasons for these questions, or they may be
intended as fun but meaningless challenges (I have no problem with
that) but until I know *why* using the features of the language is not
an acceptable solution I'm not inclined to be helpful.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #13

P: n/a
Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<sl*******************@hehe.cl.cam.ac.uk>...
ankursinha wrote:
Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.
This invokes undefined behaviour, because variable length array types
aren't compatible with normal array types, but it's the closest I
could get. It's C99, obviously.

#include <stdio.h>
int main(int argc, char *argv[static printf("Hello World\n"), 0])
{
}


This code doesnt work(atleast on my pc).it says expression syntax &
array bounds misssing.
im using the old TurboC++ compiler.
also,isnt argv supposed to have only one array size value when u
declare it
as : char *argv[].

How is static printf ("Heloo") supposed to work.
It gives an error even if it is given as a normal statement.

static printf("hello");
There's also

#error "Hello World"

but I don't consider that a program.

Jeremy.


true.
Nov 14 '05 #14

P: n/a
On 2004-02-19, ankursinha <an*********@hotmail.com> wrote:
Hi,

Is it possible to write a C program that prints "Hello World" on
screen without having a single semi-colon in the entire program? The
extra constraint here is that u r not allowed to use if,while,switch
etc.


This works on my system:

$ cat hello.c
# /*
echo Hello World
exit 0
# */
int main(void) {}
$ ./hello.c
Hello World
$ cc hello.c
$

-- James
Nov 14 '05 #15

P: n/a
On 19 Feb 2004 20:32:21 -0800, in comp.lang.c, ankursinha wrote:
:Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<sl*******************@hehe.cl.cam.ac.uk>...
:> ankursinha wrote:
:> > Is it possible to write a C program that prints "Hello World" on screen without
:> > having a single semi-colon in the entire program?
:> > The extra constraint here is that u r not allowed to use if,while,switch etc.
:>
<snip>
:> #include <stdio.h>
:> int main(int argc, char *argv[static printf("Hello World\n"), 0])
:> {
:> }
:
:This code doesnt work(atleast on my pc).it says expression syntax &
:array bounds misssing. im using the old TurboC++ compiler.

Get a new compiler. If you don't want to pay for one, get a free
compiler like gcc (part of cygwin), mingw or lcc. I don't know whether
any of these support C99 features yet. The latest version of gcc might.
On *nix systems, I think gcc supports many of the C99 features.

As for Jeremy's code, I am not sure how it works, but it does (with gcc
3.2.2). I think the whole expression within [] is treated as the size of
the array and since it is a comma separated expression, the LHS is
evaluated, result discarded and, the RHS is evaluated.

Someone please tell me if this is right. Also, why is static required
there? Confused...

Have a nice day,
Pradeep
--
R Pradeep Chandran pradeep DOT chandran AT sisl.co.in
All opinions are mine and do not represent those of my employer.
Nov 14 '05 #16

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
an*********@hotmail.com (ankursinha) writes:
Is it possible to write a C program that prints "Hello World" on
screen without having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use
if,while,switch etc.


Why would you want to do that? Are you and Aniruddha taking the same
class? (Aniruddha has been posting to comp.lang.c.moderated asking
how to access command line arguments without using argc and argv, and
how to emulate sizeof without using sizeof.)


Well, emulating sizeof is an enlightening exercise for anyone who has
taken a course on basic C programming, while the current problem only
has a sensible solution in C99.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #17

P: n/a
In <c1**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Keith Thompson <ks***@mib.org> scribbled the following:
an*********@hotmail.com (ankursinha) writes:
Is it possible to write a C program that prints "Hello World" on
screen without having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use
if,while,switch etc.

Why would you want to do that? Are you and Aniruddha taking the same
class? (Aniruddha has been posting to comp.lang.c.moderated asking
how to access command line arguments without using argc and argv, and
how to emulate sizeof without using sizeof.)


Accessing command line arguments without using argc and argv is easy.
Just name the parameters something else. =)


That's the point: in his example, main() was defined without arguments!

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #18

P: n/a
In <95**************************@posting.google.com > an*********@hotmail.com (ankursinha) writes:
Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<sl*******************@hehe.cl.cam.ac.uk>...
ankursinha wrote:
> Is it possible to write a C program that prints "Hello World" on screen without
> having a single semi-colon in the entire program?
> The extra constraint here is that u r not allowed to use if,while,switch etc.


This invokes undefined behaviour, because variable length array types
aren't compatible with normal array types, but it's the closest I
could get. It's C99, obviously. ^^^^^^^^^^^^^^^^^^^
#include <stdio.h>
int main(int argc, char *argv[static printf("Hello World\n"), 0])
{
}


This code doesnt work(atleast on my pc).it says expression syntax &
array bounds misssing.
im using the old TurboC++ compiler.

^^^^^^^^^^^^^^^^
Are you reading impaired or merely a patent idiot?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #19

P: n/a
In <a0********************************@4ax.com> R Pradeep Chandran <se*@sig.below> writes:
On 19 Feb 2004 20:32:21 -0800, in comp.lang.c, ankursinha wrote:
:Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<sl*******************@hehe.cl.cam.ac.uk>...
:> ankursinha wrote:
:> > Is it possible to write a C program that prints "Hello World" on screen without
:> > having a single semi-colon in the entire program?
:> > The extra constraint here is that u r not allowed to use if,while,switch etc.
:>
<snip>
:> #include <stdio.h>
:> int main(int argc, char *argv[static printf("Hello World\n"), 0])
:> {
:> }
:
:This code doesnt work(atleast on my pc).it says expression syntax &
:array bounds misssing. im using the old TurboC++ compiler.

Get a new compiler. If you don't want to pay for one, get a free
compiler like gcc (part of cygwin), mingw or lcc. I don't know whether
any of these support C99 features yet. The latest version of gcc might.
On *nix systems, I think gcc supports many of the C99 features.

As for Jeremy's code, I am not sure how it works, but it does (with gcc
3.2.2). I think the whole expression within [] is treated as the size of
the array and since it is a comma separated expression, the LHS is
evaluated, result discarded and, the RHS is evaluated.

Someone please tell me if this is right.
Yes, argv is defined as a VLA (variable length array). It is not clear
if C99 allows the second parameter of main() to be defined this way, so
the code is not necessarily correct.
Also, why is static required there? Confused...


It's another C99 feature, but it is not needed here. Without static,
things would be even simpler:

int main(int argc, char *argv[printf("Hello World\n")]) {}

because the value used in the VLA definition is completely ignored after
being evaluated for any side effects, the effective type of argv being
char **, as usual.

The big point, however, is whether C99 allows the second parameter of
main() to be defined as a VLA.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #20

P: n/a
Dan Pop wrote:
It's another C99 feature, but it is not needed here. Without static,
things would be even simpler:

int main(int argc, char *argv[printf("Hello World\n")]) {}

because the value used in the VLA definition is completely ignored after
being evaluated for any side effects, the effective type of argv being
char **, as usual.


I couldn't find where the standard says the expression is evaluated
for side effects, which is why I added the 'static' (which clearly
requires evaluation of the expression). I took the following to mean
that the expression is not evaluated:

5 If the size is an expression that is not an integer constant
expression: if it occurs in a declaration at function prototype
scope, it is treated as if it were replaced by *; otherwise, each
time it is evaluated it shall have a value greater than zero.

Jeremy.
Nov 14 '05 #21

P: n/a
Keith Thompson <ks***@mib.org> wrote in message news:<ln************@nuthaus.mib.org>...
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Keith Thompson <ks***@mib.org> scribbled the following:
an*********@hotmail.com (ankursinha) writes:
> Is it possible to write a C program that prints "Hello World" on
> screen without having a single semi-colon in the entire program?
> The extra constraint here is that u r not allowed to use
> if,while,switch etc. Why would you want to do that? Are you and Aniruddha taking the same
class? (Aniruddha has been posting to comp.lang.c.moderated asking
how to access command line arguments without using argc and argv, and
how to emulate sizeof without using sizeof.)

I have no idea who Anirudha is???
Accessing command line arguments without using argc and argv is easy.
Just name the parameters something else. =)
That was one of the proposed solutions over in clcm, but the Aniruddha
said it didn't fit the specification (without explaining why using
argc and argv wasn't acceptable).

I suspect some instructor in India is assigning these silly problems
without making it sufficiently clear that asking Usenet to do your
homework for you is not acceptable. (I'm not picking on India; of the
two blatant examples of this I've seen, both posters have
Indian-sounding names, one posted from a *.in address, and the other
used a hotmail address.) That's just speculation; there may be no
connection between the two posters, but the questions have the same
feel to them.


I am from India but this is not homework nor has anyone asked me this question
u may call me stupid but i read those classic interview questions(i agree such
questions shouldnt be asked at interviews) and i just thought whether such a
variant wsa possible.That's the reason behind such a question.
There may be legitimate reasons for these questions, or they may be
intended as fun but meaningless challenges (I have no problem with
that) but until I know *why* using the features of the language is not
an acceptable solution
U may call it a fun challenge.
I'm not inclined to be helpful.


Thanx a lot.Enjoy Life.
Nov 14 '05 #22

P: n/a
Jeremy Yallop <je****@jdyallop.freeserve.co.uk> wrote in message news:<sl*******************@hehe.cl.cam.ac.uk>...
ankursinha wrote:
Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.
This invokes undefined behaviour, because variable length array types
aren't compatible with normal array types, but it's the closest I
could get. It's C99, obviously.

#include <stdio.h>
int main(int argc, char *argv[static printf("Hello World\n"), 0])
{
}


Shouldnt argv have only one size value in array declaration?

char *argv[] or char **argv

Also,could u pls explain the reason of using static.
There's also

#error "Hello World"

but I don't consider that a program.

Jeremy.

Nov 14 '05 #23

P: n/a
an*********@hotmail.com (ankursinha) writes:
[...]
I suspect some instructor in India is assigning these silly problems
without making it sufficiently clear that asking Usenet to do your
homework for you is not acceptable. (I'm not picking on India; of the
two blatant examples of this I've seen, both posters have
Indian-sounding names, one posted from a *.in address, and the other
used a hotmail address.) That's just speculation; there may be no
connection between the two posters, but the questions have the same
feel to them.


I am from India but this is not homework nor has anyone asked me
this question u may call me stupid but i read those classic
interview questions(i agree such questions shouldnt be asked at
interviews) and i just thought whether such a variant wsa
possible.That's the reason behind such a question.
There may be legitimate reasons for these questions, or they may be
intended as fun but meaningless challenges (I have no problem with
that) but until I know *why* using the features of the language is not
an acceptable solution


U may call it a fun challenge.
I'm not inclined to be helpful.


Thanx a lot.Enjoy Life.


Ok, if it's just a fun challenge, that's perfectly fine with me. In
the future, I suggest making that more explicit, just to avoid
possible misunderstandings. We do get a lot of people coming here
asking us to do their homework for them; if you ask a question that
looks like it could be homework, it's a good idea to provide some
background.

I'm glad to learn that my suspiciouns were unfounded. I'd gladly jump
into the discussion (I like silly puzzles), but I don't have any ideas
or sufficient time to come up with any.

One piece of friendly advice: the abbreviation "u" for "you" is
generally frowned upon here. We discussed this at far too much length
not long ago, so I won't go into the reasoning; you can search the
archives, take my word for it, or ignore me if you wish.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #24

P: n/a
Keith Thompson <ks***@mib.org> writes:
[...]
I'm glad to learn that my suspiciouns were unfounded.


And less glad to learn that they were misspelled. 8-)}

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #25

P: n/a
Dan Pop wrote:
In <40**********************@news.club-internet.fr> Guillaume <gr*******@NO-SPAMmail.com> writes:

Is the solution to this question possible in c(or c++ for that matter)?


You could try:
int main(int argc, char **argv)
{
if (printf("Hello world!\n")) {}
}
Fits the bill?

When did the following statement disappear from his post?

The extra constraint here is that u r not allowed to use
if,while,switch etc.


When did `u r' become correct English?

--
My address is yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
Note: Rot13 and convert spelled-out numbers to numerical equivalents.
Nov 14 '05 #26

P: n/a
August Derleth wrote:

When did the following statement disappear from his post?

The extra constraint here is that u r not allowed to use
if,while,switch etc.

When did `u r' become correct English?


Didn't u get the memo?

Sidney

Nov 14 '05 #27

P: n/a
Jeremy Yallop wrote:
Dan Pop wrote:
It's another C99 feature, but it is not needed here. Without static,
things would be even simpler:

int main(int argc, char *argv[printf("Hello World\n")]) {}

because the value used in the VLA definition is completely ignored after
being evaluated for any side effects, the effective type of argv being
char **, as usual.


I couldn't find where the standard says the expression is evaluated
for side effects, which is why I added the 'static' (which clearly
requires evaluation of the expression). I took the following to mean
that the expression is not evaluated:

5 If the size is an expression that is not an integer constant
expression: if it occurs in a declaration at function prototype
scope, it is treated as if it were replaced by *; otherwise, each
time it is evaluated it shall have a value greater than zero.


I've just noticed that this doesn't apply because the VLA declaration
is not at function prototype scope.

Jeremy.
Nov 14 '05 #28

P: n/a
Dan Pop wrote:
In <40**********************@news.club-internet.fr> Guillaume <gr*******@NO-SPAMmail.com> writes:

Is the solution to this question possible in c(or c++ for that matter)?
You could try:
int main(int argc, char **argv)
{
if (printf("Hello world!\n")) {}
}
Fits the bill?

When did the following statement disappear from his post?

The extra constraint here is that u r not allowed to use
if,while,switch etc.


He's not ur, so he gets to use them. Only ur can't use them,
whoever he is.
Dan

Nov 14 '05 #29

P: n/a
"Kevin Handy" <kt*@srv.net> wrote in message
news:IZ****************@fe01.usenetserver.com...
He's not ur, so he gets to use them. Only ur can't use them,
whoever he is.


How do you know ur is not a she?
Nov 14 '05 #30

P: n/a
Peter Pichler wrote:
"Kevin Handy" <kt*@srv.net> wrote in message
He's not ur, so he gets to use them. Only ur can't use them,
whoever he is.


How do you know ur is not a she?


Because Ur is a city in antiquity.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #31

P: n/a
CBFalconer wrote:

Peter Pichler wrote:
"Kevin Handy" <kt*@srv.net> wrote in message
He's not ur, so he gets to use them. Only ur can't use them,
whoever he is.


How do you know ur is not a she?


Because Ur is a city in antiquity.

From about 3000 BC. Birthplace of Abraham. In southeastern Iraq.
Abandoned around 500 BC.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #32

P: n/a
> Is it possible to write a C program that prints "Hello World" on screen without
having a single semi-colon in the entire program?
The extra constraint here is that u r not allowed to use if,while,switch etc.


Solution 1:

#error "Hello World"

(it isn't specified at what stage the text has to be "printed"
on the "screen")

Solution 2:

No.

(there might not be a screen)

Solution 3:

#include <stdio.h>
int main(void)
{
puts("Hello World");;
}

(only double semi-colons were used)
Nov 14 '05 #33

P: n/a
Keith Thompson <ks***@mib.org> writes:
[...]
I suspect some instructor in India is assigning these silly problems
without making it sufficiently clear that asking Usenet to do your
homework for you is not acceptable. (I'm not picking on India; of the
two blatant examples of this I've seen, both posters have
Indian-sounding names, one posted from a *.in address, and the other
used a hotmail address.) That's just speculation; there may be no
connection between the two posters, but the questions have the same
feel to them.

There may be legitimate reasons for these questions, or they may be
intended as fun but meaningless challenges (I have no problem with
that) but until I know *why* using the features of the language is not
an acceptable solution I'm not inclined to be helpful.


Apparently there was no connection between the two articles, and it
was foolish of me to assume that there was. I saw two seemingly
similar posts, both from people with seemingly Indian names, and
assumed the likelihood of a connection. In fact, India is an
extremely large country, and my assumption was poorly thought out --
not unlike saying, "You must have met John Smith; he lives in
America." I apologize.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #34

This discussion thread is closed

Replies have been disabled for this discussion.