Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.
@  agyat : (19 April 2013 - 02:49 AM) There may be two possible answers for that ....
@  yordan : (18 April 2013 - 09:35 PM) however, why this mixing of capital letters in the middle of your text?

Photo
- - - - -

C Puzzles


6 replies to this topic

#1 sureshkmit

sureshkmit

    Newbie [ Level 1 ]

  • Members
  • 2 posts

Posted 07 January 2008 - 06:25 AM

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?

#2 Guest_(G)Anubhav Baweja_*

Guest_(G)Anubhav Baweja_*
  • Guests

Posted 14 December 2009 - 08:24 AM

If you expect "NONE" is the output, u are wrong. Wats the output & How?C Puzzles

The 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

#3 Guest_(G)rajender_*

Guest_(G)rajender_*
  • Guests

Posted 07 December 2010 - 08:35 PM

If you expect "NONE" is the output, u are wrong. Wats the output & How?C Puzzles

the structure of switch case is:

switch(a)

{

case 1:printf("oneand");   //not case '1':printf("oneand");

}

-reply by rajender

 



#4 yordan

yordan

    Way Out Of Control - You need a life :)

  • [MODERATOR]
  • 4,677 posts

Posted 11 December 2010 - 05:55 PM

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. :P
And if you were a skilled c developer, you should not do such obvious syntax errors. :P

#5 FirefoxRocks

FirefoxRocks

    Super Member

  • [HOSTED]
  • 988 posts
  • Gender:Male
  • Location:Ontario, Canada
  • myCENTs:92.36

Posted 08 May 2011 - 11:21 PM

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.

#6 Guest_(G)S.FREEDA_*

Guest_(G)S.FREEDA_*
  • Guests

Posted 27 June 2011 - 01:43 PM

for loop in CC Puzzles

StartF=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



#7 Guest_(G)koushik sarma_*

Guest_(G)koushik sarma_*
  • Guests

Posted 19 September 2011 - 03:10 PM

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





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users