reply the answer

R

Richard Heathfield

Eric Sosman said:

I'm curious. I can see the print part easily enough, but how are you
going to handle the return statement? (Email reply welcome if you don't
want to spoil the OP's fun.)
 
H

Harald van =?UTF-8?B?RMSzaw==?=

Richard said:
Eric Sosman said:

I'm curious. I can see the print part easily enough, but how are you
going to handle the return statement? (Email reply welcome if you don't
want to spoil the OP's fun.)

There is no need for a return statement.
 
C

CBFalconer

Richard said:
Eric Sosman said:

I'm curious. I can see the print part easily enough, but how are
you going to handle the return statement? (Email reply welcome if
you don't want to spoil the OP's fun.)

Use C99.
 
H

Harald van =?UTF-8?B?RMSzaw==?=

Richard said:
Harald van D?k said:

Oh. *That* kind of program. Count me out.

I'm not sure what you mean by "that" kind. You don't need a return statement
in a strictly conforming C90 program that prints "HELLOWORLD" and exits
successfully.

#include <stdio.h>
#include <stdlib.h>
int main(void) {
puts("HELLOWORLD");
exit(0);
}

Getting rid of the semicolons for the exit call can be done the same way as
for puts.
 
M

Malcolm McLean

Harald van D?k said:
I'm not sure what you mean by "that" kind. You don't need a return
statement
in a strictly conforming C90 program that prints "HELLOWORLD" and exits
successfully.

#include <stdio.h>
#include <stdlib.h>
int main(void) {
puts("HELLOWORLD");
exit(0);
}

Getting rid of the semicolons for the exit call can be done the same way
as
for puts.
For top notch credit see if you can return EXIT_FAILURE if the puts call
fails.
 
S

sravan_reddy001

void main()
{
if(printf("Hello World")){}
}

this is the simple way. and even u can assign the values without using
semi-colon. if() is the best to use among
 
R

Richard Heathfield

sravan_reddy001 said:
void main()
{
if(printf("Hello World")){}
}

this is the simple way.

Alas, it doesn't conform to the specification, which called for a C
program.
 
R

Richard Heathfield

Harald van D?k said:
I'm not sure what you mean by "that" kind. You don't need a return
statement in a strictly conforming C90 program that prints
"HELLOWORLD" and exits successfully.

Correction: *you* might not need a return statement there, but if I
can't have one there, I'm taking my ball home.
 
M

Mark McIntyre

Harald van D?k said:


Oh. *That* kind of program. Count me out.

Whats wrong with a programme that conforms to the standard?

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
M

Mark McIntyre

Harald van D?k said:


Correction: *you* might not need a return statement there, but if I
can't have one there, I'm taking my ball home.

Fine, but its not our problem if some posters refuse to accept
standards-conforming code.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
E

Eric Sosman

Richard said:
Eric Sosman said:


I'm curious. I can see the print part easily enough, but how are you
going to handle the return statement? (Email reply welcome if you don't
want to spoil the OP's fun.)

Here's a program that doesn't fulfill the requirements,
but that outputs a hint about one way to satisfy them:

/* hint.c
* Compile in whatever way your system demands,
* then execute with the command-line arguments
* firstname lastname wants a hint
* substituting your own first and last names
* for `firstname' and `lastname'.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argv, char **argc)
{
if (argv != strlen("guthena" + 1)
|| strcmp(argc[3], "wants")
|| strcmp("hint", argc[5])
|| *argc[4]++-*++argc[3]
|| *argc[4]) {
fputs ("No hints for people who can't "
"follow simple directions!\n", stderr);
return EXIT_FAILURE;
}
printf ("This hint is for the sole use of %s ", *++argc);
printf ("%s: %d.", *++argc, argv--);
printf ("%.1f\n", argv * 21 / 10.0);
return EXIT_SUCCESS;
}
 
K

Keith Thompson

Richard Heathfield said:
sravan_reddy001 said:

Alas, it doesn't conform to the specification, which called for a C
program.

I'd say that a "conforming program", as defined by C99 4p7, qualifies
as a C program. I believe the above is a conforming program.

(The real problem is that the standard's definition of "conforming
program" is nearly useless.)
 
C

CBFalconer

sravan_reddy001 said:
void main()
{
if(printf("Hello World")){}
}

this is the simple way. and even u can assign the values without using
semi-colon. if() is the best to use among

Not fully portable. Requires a #include statement, a type for
main, and C99.
 
R

Richard Heathfield

Keith Thompson said:
I'd say that a "conforming program", as defined by C99 4p7, qualifies
as a C program.

I wouldn't say that. The definition is too loose to be useful. It
effectively means that any bug and any abuse is okay so long as the
compiler can be persuade to bumble its way through the code and produce
an executable.
I believe the above is a conforming program.

So are Fortran programs, apparently. I don't find this to be
particularly useful in deciding what are, and what are not, C programs.
(The real problem is that the standard's definition of "conforming
program" is nearly useless.)

Yes. I tend to think of "C program" as "program that is accepted by a
conforming newsgroup". :)
 
R

Richard Heathfield

CBFalconer said:

I don't have the patience to wait that long. Nor do I have the
inclination to use ugly features just because they're legal.
 
D

Dave Vandervies

Richard said:
Eric Sosman said:


I'm curious. I can see the print part easily enough, but how are you
going to handle the return statement? (Email reply welcome if you don't
want to spoil the OP's fun.)

Here's a program that doesn't fulfill the requirements,
but that outputs a hint about one way to satisfy them:

/* hint.c
* Compile in whatever way your system demands,
* then execute with the command-line arguments
* firstname lastname wants a hint
* substituting your own first and last names
* for `firstname' and `lastname'.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argv, char **argc)
{
if (argv != strlen("guthena" + 1)
|| strcmp(argc[3], "wants")
|| strcmp("hint", argc[5])
|| *argc[4]++-*++argc[3]
|| *argc[4]) {
fputs ("No hints for people who can't "
"follow simple directions!\n", stderr);
return EXIT_FAILURE;
}
printf ("This hint is for the sole use of %s ", *++argc);
printf ("%s: %d.", *++argc, argv--);
printf ("%.1f\n", argv * 21 / 10.0);
return EXIT_SUCCESS;
}

If I'm interpreting your hint correctly, I don't think it's actually
helpful; my understanding of the OP's problem is that the program itself,
not the translator, is supposed to be producing the output.


dave
 
E

Eric Sosman

Dave said:
Richard said:
Eric Sosman said:

guthena wrote:
Can we write a C programe with out a semicolon ? printing HELLOWORLD
!
Yes.
I'm curious. I can see the print part easily enough, but how are you
going to handle the return statement? (Email reply welcome if you don't
want to spoil the OP's fun.)
Here's a program that doesn't fulfill the requirements,
but that outputs a hint about one way to satisfy them:

/* hint.c
* Compile in whatever way your system demands,
* then execute with the command-line arguments
* firstname lastname wants a hint
* substituting your own first and last names
* for `firstname' and `lastname'.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argv, char **argc)
{
if (argv != strlen("guthena" + 1)
|| strcmp(argc[3], "wants")
|| strcmp("hint", argc[5])
|| *argc[4]++-*++argc[3]
|| *argc[4]) {
fputs ("No hints for people who can't "
"follow simple directions!\n", stderr);
return EXIT_FAILURE;
}
printf ("This hint is for the sole use of %s ", *++argc);
printf ("%s: %d.", *++argc, argv--);
printf ("%.1f\n", argv * 21 / 10.0);
return EXIT_SUCCESS;
}

If I'm interpreting your hint correctly, I don't think it's actually
helpful; my understanding of the OP's problem is that the program itself,
not the translator, is supposed to be producing the output.

"printing HELLOWORLD !" was the specification; the only
constraint was that it be a "C programe." You interpret the
requirements your way; I'll interpret them in mine. (It is
on this sacred principle of unchallengable orneriness that
the DeathStation 9000 was built.)
 

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,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top