Tricky Questions

Reply

Join Date: Jun 2006
Posts: 1
Reputation: Antonyraj is an unknown quantity at this point 
Solved Threads: 0
Antonyraj Antonyraj is offline Offline
Newbie Poster

Re: Tricky Questions

 
0
  #11
Jun 1st, 2006
Originally Posted by ivanCeras
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"))
{

}
}
Last edited by Dave Sinkula; Jun 1st, 2006 at 10:27 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: Tricky Questions

 
0
  #12
Jun 1st, 2006
Now spammers will kill your ID
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 598
Reputation: anupam_smart is an unknown quantity at this point 
Solved Threads: 4
anupam_smart's Avatar
anupam_smart anupam_smart is offline Offline
Posting Pro

Re: Tricky Questions

 
0
  #13
Jun 2nd, 2006
Originally Posted by Antonyraj
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 ........???
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 26
Reputation: dude543 is an unknown quantity at this point 
Solved Threads: 0
dude543 dude543 is offline Offline
Light Poster

Re: Tricky Questions

 
0
  #14
Jun 2nd, 2006
I too failed to solve "A 'C' program without using any loop (if, for, while,etc...) to print numbers."

unless it is somthing like
  1. printf("1, 2, 3, 4....\n");


Google nither helped. Any ideas ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,630
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 718
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Tricky Questions

 
0
  #15
Jun 2nd, 2006
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 598
Reputation: anupam_smart is an unknown quantity at this point 
Solved Threads: 4
anupam_smart's Avatar
anupam_smart anupam_smart is offline Offline
Posting Pro

Re: Tricky Questions

 
0
  #16
Jun 3rd, 2006
Originally Posted by Narue
>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...


  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int n;
  6. int prno();
  7. clrscr();
  8. printf("\n Enter the no. upto which u want to print the no.=");
  9. scanf("%d",&n);
  10. n++;
  11. prno(n);
  12. getch();
  13. }
  14. prno(int i);
  15. {
  16. i--;
  17. (i<=0)?printf("\n Thank u") : prno(i);
  18. printf("\n %d",i);
  19. return(i);
  20. }

Have fun with 'C' :!:
Last edited by Dave Sinkula; Jun 3rd, 2006 at 9:27 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 26
Reputation: dude543 is an unknown quantity at this point 
Solved Threads: 0
dude543 dude543 is offline Offline
Light Poster

Re: Tricky Questions

 
0
  #17
Jun 3rd, 2006
Originally Posted by Narue
>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
  1. 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'"
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,359
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 238
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Tricky Questions

 
0
  #18
Jun 3rd, 2006
Originally Posted by dude543
But in any case we are not allowed to test with "if".
Hmm...
Originally Posted by tlly
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).
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC