^^good ...
u and QM have solved the puzzle..both of u get points..
Try solving it without using even switch....let's see who solves then..
#include <stdio.h>
#include <conio.h>
int main (void){
printf("\nHello!\nContinue(y/n)");
(getche()=='y'&&printf("\b "))?main():printf("\b \nBye, Press any key to exit.")&&getche()&&printf("\b ");
}
hey adi007 i hope u dont mind if i ask a small question here...der was no activity in d thread 4 quite sm time now so i thot ill post...
hey 1 small question from my side......its extremely simple..........
Write a program 2 print "yes i can print without ;"........
obviously ne1 can do it without restrictions...
restrictions:
1.only stdio.h 2 b used
2.no macros
3.program inside main() shd b only 1 line.
4.no user defined functions.
5.no semicolon to be used newhr in the entire program.
i know its extremely simple n all of u will get it very easily........
#include <stdio.h>
void main(void)
{
if (printf ("yes i can print without %c",59)){}
}
i guess so.yes dats the right answer.........but dat was 2 simple
10
9
8
7
6
5
4
3
2
1
i guess so.
Ok, here's one from my side. The program should output:
Code:10 9 8 7 6 5 4 3 2 1
Without the rules, this shud be any C learners second program after Hello! World. So here they are:
1. One Variable.
2. Two lines including variable declaration.
3. No functions except main.
4. No if, switch or any conditional statement (Yes, don't even use ? : conditional statement)
5. No for, do, while or goto.
6. printf statement to print this directly won't make it a puzzle. So don't try that. Use printf to print one number at a time.
7. Don't try multiple statements with semicolons all in one line. Thats lame too.
8. No global declarations or macros.
9. Maximum 2 header files, stdio.h and conio.h
Not so easy. Lets see. I'll post the solution after 2 weeks, if noone is able to solve it.
#include <stdio.h>
int main(void)
{
static int i=10;
return printf("%d\n",i--)&&i&&main();
}
read as "&& i && main();"
He's recursively calling main() till 'i' becomes 0