G
guthena
Can we write a C programe with out a semicolon ? printing HELLOWORLD !
guthena said:Can we write a C programe with out a semicolon ? printing HELLOWORLD !
Yes.
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.
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.)
Richard said:Harald van D?k said:
Oh. *That* kind of program. Count me out.
For top notch credit see if you can return EXIT_FAILURE if the puts callHarald 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.
void main()
{
if(printf("Hello World")){}
}
this is the simple way.
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.
Harald van D?k said:
Oh. *That* kind of program. Count me out.
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.
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.)
Richard Heathfield said:sravan_reddy001 said:
Alas, it doesn't conform to the specification, which called for a C
program.
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
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.)
Use C99.
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;
}
Dave said:Here's a program that doesn't fulfill the requirements,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.)
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.
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.