I've got a 2 tricky questions for u. Can anyone write:
1). A "Hello World" program in 'C' without using any semicolon.
2). A 'C' program without using any loop (if, for, while,etc...) to print numbers.

A friend gave me those questions but up till now i have not been able to do them..!!

Recommended Answers

All 17 Replies

I've got a 2 tricky questions for u. Can anyone write:

Yes. They are so commonly asked that googling them ought to spoonfeed you enough results to choke a donkey.

Member Avatar for iamthwee

What is this 'google' you talk of? :?:

>A friend gave me those questions but up till now i have not been able to do them..!!
Is your "friend" a teacher who teaches C and who's class you happen to be in?

What is this 'google' you talk of? :?:

Its a search engine for the internet. see www.google.com. type in a key word(s) and it will try to find it. Sometimes it works ok, but often it will return trillions of answers :mrgreen:

Member Avatar for iamthwee

Its a search engine for the internet. see www.google.com. type in a key word(s) and it will try to find it. Sometimes it works ok, but often it will return trillions of answers :mrgreen:

*smartass* - stolen from narue.
:cheesy:

1). A "Hello World" program in 'C' without using any semicolon.

while((std::cout << "Hello World"<< std::endl) == 0){}

1). A "Hello World" program in 'C' without using any semicolon.

while((std::cout << "Hello World"<< std::endl) == 0){}

What strange C you write. :p

What strange C you write. :p

:eek: :eek:

I've got a 2 tricky questions for u. Can anyone write:
1). A "Hello World" program in 'C' without using any semicolon.
2). A 'C' program without using any loop (if, for, while,etc...) to print numbers.

A friend gave me those questions but up till now i have not been able to do them..!!

a sophisticated,convoluted code any other programmer make proud of .... is a bad programming practice... why not keep it simple and readable... <dietel & dietel books..>

a sophisticated,convoluted code any other programmer make proud of .... is a bad programming practice... why not keep it simple and readable... <dietel & dietel books..>

This is the program without using semicolon. Iam antony from india my mail id <<email snipped>> welcome some more queries.

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

}
}

Now spammers will kill your ID :) :)

This is the program without using semicolon. Iam antony from india my mail id <<email snipped>> welcome some more queries.

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

}
}

Oooooops....
i m a bit late.
Antonyraj put the same code which otherwise i would have done.:) :)
Right now.... trying to solve the other one.
i think functions would be a way to solve it ........???:idea:

I too failed to solve "A 'C' program without using any loop (if, for, while,etc...) to print numbers."

unless it is somthing like

printf("1,  2,  3,  4....\n");

;)

Google nither helped. Any ideas ?

>Google nither helped.
I get the feeling you didn't look very hard. Have you considered recursion? What about goto? Neither of those are considered to be loop constructs.

>Google nither helped.
I get the feeling you didn't look very hard. Have you considered recursion? What about goto? Neither of those are considered to be loop constructs.

yes...
I tried it and hey tlly i come up with the following code.......
May be this would suit ur expectatios to the best.So, check this out...
:idea: :idea: :idea:

#include<stdio.h>
#include<conio.h>
void main()
{
    int n;
    int prno();
    clrscr();
    printf("\n Enter the no. upto which u want to print the no.=");
    scanf("%d",&n);
    n++;
    prno(n);
    getch();
}
prno(int i);
{
    i--;
    (i<=0)?printf("\n Thank u") : prno(i);
    printf("\n %d",i);
    return(i);
}

Have fun with 'C':) :) :) :!:

>Google nither helped.
I get the feeling you didn't look very hard. Have you considered recursion? What about goto? Neither of those are considered to be loop constructs.

goto was the first thing that came to my mind.
recursion was the seconed thing.

But in any case we are not allowed to test with "if".
I tought about simple condition like this

i = ( i < 10 ) ? i+1 : i ;

But its like using "if".

I tought about macros. But thats using "if" and saying
"I am not using 'if'"

But in any case we are not allowed to test with "if".

Hmm...

2). A 'C' program without using any loop (if, for, while,etc...) to print numbers.

Confusing directions -- you can't use a loop, but an if statement is not an iteration statement (a loop construct).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.