Topic: without semicolon?

Its a common problem. It was discussed in projanmo forum too. But I am going 1 step forward with the conditions.

Problem: write a C program that prints "Hello world" without any semicolon in it.
Condition: You can not use any control statement (eg, if, while ) or any conditional operator ( &&, || )

It may be very easy if you have already tried it.  PM me the solution.  when finished I'll publish all of submitted solution along with the result. smile

http://url.ie/zybhttp://url.ie/zydhttp://url.ie/zyc
মুখে তুলে কেউ খাইয়ে দেবে না। নিজের হাতেই সেটা করতে হবে।

Re: without semicolon?

thinking thinking thinking
It's gonna a tough problem. But, watching the code, it becomes easy ghusi
with condition, it would very easy

#include<stdio.h>
#include<conio.h>
 
int main()
{
    if(printf("hello world"))
    getch();
}

My brain is not working crying

Last edited by Tareq (March 24, 2009 10:06 pm)

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

I am failed to solve that crying

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

brokenheart me too. Couldnt solve that

Re: without semicolon?

There are some solutions possible for this problem. I am giving a hint on a bit cheating one. The hint is:

You can define preprocessor directive during compiling!

Re: without semicolon?

I got it and i solved it dancing
I have send the PM to shiplu vai big_smile
Thanks nasim vai. That was so funny hairpull

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

The solution is :
Open notepad
Write "Hello World" without qoute
Switch on your printer
Go to File>Print
Finally you will get a output "Hello World" without semicolon tongue_smile

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

Tareq, you used a semicolon. The problem states "write a C program that prints "Hello world" without any semicolon in it "

It must be a program. and it must be written in C. It doesn't say to print "Hello world" only.

None of the submitted solution is correct.

should you try more or I'll finish it!! big_smile

http://url.ie/zybhttp://url.ie/zydhttp://url.ie/zyc
মুখে তুলে কেউ খাইয়ে দেবে না। নিজের হাতেই সেটা করতে হবে।

Re: without semicolon?

shiplu vai, you can finish it if you want. I can't do that crying

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

#include<stdio.h>
int main (int argc, char *argv[printf("Hello world")]) {}
#include<stdio.h>
int main (int argc, char **argv, int helloWorld[printf("Hello World!")]) {}

Last edited by shiplu (March 27, 2009 3:06 am)

http://url.ie/zybhttp://url.ie/zydhttp://url.ie/zyc
মুখে তুলে কেউ খাইয়ে দেবে না। নিজের হাতেই সেটা করতে হবে।

Re: without semicolon?

shiplu vai, where did you compiled it? i tried dev c++ and turbo c. But it shows errors hehe

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

Tareq wrote:

shiplu vai, where did you compiled it? i tried dev c++ and turbo c. But it shows errors hehe

I compiled it in gcc version 4.3.2 in my ubuntu.
Works totally perfect!
what is dev C++?? try C compiler.

http://url.ie/zybhttp://url.ie/zydhttp://url.ie/zyc
মুখে তুলে কেউ খাইয়ে দেবে না। নিজের হাতেই সেটা করতে হবে।

Re: without semicolon?

This is C99 code, meaning old compilers cannot compile this. So Turbo C cannot compile it. Dev C++ is very ugly IDE. Why do you use it?

Re: without semicolon?

Nasim vai, can you suggest a IDE for me?

As you said to use a pre-processor directive, i used this one. Can you please submit a solve using pre-processor directive big_smile

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

Use Eclipse as an IDE. It is an all in all IDE for a very wide range of languages. You can code in whatever language you like.

Here's the hello.c program

#include <stdio.h>
 
main() {
    printf("Hello world") __
}

Now, compile this with gcc by

gcc -D__=\; hello.c

Re: without semicolon?

main() {
    printf("Hello world") __
}

what is this __ ? what does it really do big_smile

Once i downloaded Zend Studio for Eclipse. But did not understand it's usage worried
Now also i have installed eclipse-cpp-ganymede-win32. The whole thing is same and again i did not understand it hairpull

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

__ is nothing. We are cheating with it. We define __ as ; while compiling. The compiler substitutes __ with ; before the compiling process. Even we did not specify ; in our code, actually we are using it just by redefining as __.

Re: without semicolon?

we are cheating? so my code was right thinking

#include<stdio.h>
#include<conio.h>
#define SEMICOLON ;
int main()
{
    printf("hello world") SEMICOLON
    getch();
}
http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php

Re: without semicolon?

In fact, shiplu's code is also a cheating. Because you never specify the size of an array in the function arguments. That is a serious security bug. Tareq's code is exactly same as mine. However, Tareq does have a visible semicolon in his code while mine does not. The trick is -  You don't write semicolon anywhere in the code.

Re: without semicolon?

Ok, thats it. Now we need another problem. No cheating wink

http://tareq.wedevs.com/test/sig/blog_update.php
http://tareq.wedevs.com/test/sig/twitt_update.php