sureshkmit 0 Report post Posted January 7, 2008 Thanks for your interest in C programming. Here, you will find a list of interesting C programming questions/puzzles. C is the basic language for all who are in the computer science field. You can post new c questions and puzzles. Please try to avoid the duplicates.I hope that this will be very interesting and meaningful for "C" programmers.Lets us start with simple question.---------------------------------------------------------------------------------------------------------------------------------------------------- #include<stdio.h> int main() { int a=10; switch(a) { case '1': printf("ONE\n"); break; case '2': printf("TWO\n"); break; defa1ut: printf("NONE\n"); } return 0; } If you expect "NONE" is the output, u are wrong. Wats the output & How? Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 14, 2009 If you expect "NONE" is the output, u are wrong. Wats the output & How?C PuzzlesThe O/p will be NONE only because a has been declared as 10 before the loop begins. And as such the value that would be used would be the one declared.-reply by Anubhav Baweja Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 7, 2010 If you expect "NONE" is the output, u are wrong. Wats the output & How?C Puzzlesthe structure of switch case is: switch(a) { case 1:printf("oneand"); //not case '1':printf("oneand"); } -reply by rajender Share this post Link to post Share on other sites
yordan 10 Report post Posted December 11, 2010 If you expect "NONE" is the output, u are wrong. Wats the output & How?Did you really test your program example?Because the "defa1ut" syntax.Isn't it a mistyping for "default" ?In that case I would say that you are strongly faulty.As a teacher, you have to test what you are teaching us. And if you give us a copy-pastable example, this example has to be correct.If you are a noob, you should test your cases before posting them. And if you were a skilled c developer, you should not do such obvious syntax errors. Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted May 8, 2011 I would expect the program to not compile, as there is a spelling mistake in "default".Also, you are trying to compare an int to a char. Share this post Link to post Share on other sites
iGuest 3 Report post Posted June 27, 2011 for loop in CC PuzzlesStartF=1Sum=0For(j=1;j<=5;j++){For(l=j;l>=1;l--){F=f*lSum=sum+(1/f)}}Output sumEnd -reply by S.FREEDA Share this post Link to post Share on other sites
iGuest 3 Report post Posted September 19, 2011 Replying to sureshkmitReplying to sureshkmitBecause the spelling of default is wrong. C considers the word 'defalut' as a label and does not show any error message leaving the output screen blank... -reply by koushik sarma Share this post Link to post Share on other sites