LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-04-2004, 02:10 AM   #1
thomasmathew
LQ Newbie
 
Registered: Apr 2003
Location: India
Distribution: Red Hat 8.0
Posts: 23

Rep: Reputation: 15
Thumbs up A new C quiz has been posted


This is to inform you all that I have posted a new C quiz named "Brain Teasers in C". The Part - I of this is now available in the quiz section of this site. So I am requesting you all the members of this forum to take part in this quiz. I am assuring that you all will enjoy this. Moreover please pass this to others and encourage others to take part.

Beware, Think twice before answering a questions, because most of them are tricky in nature.
Comments are welcoming always. Please write your comments in the quiz section.

With regards,
Thomas
 
Old 05-04-2004, 09:01 AM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 10,606

Rep: Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652
Beat me to the announcement Thanks thomasmathew.

--jeremy
 
Old 05-04-2004, 11:01 AM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
uhh, it must be too early or somethin, but where can i find this quiz? im searchin and browsing and not seein
 
Old 05-04-2004, 11:16 AM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Quote:
Originally posted by infamous41md
uhh, it must be too early or somethin, but where can i find this quiz? im searchin and browsing and not seein
http://www.linuxquestions.org/questi...p?s=&quizid=15 Click on the quiz link at top and follow the links to the Programming section.. etc..
 
Old 05-04-2004, 11:41 AM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
Geez, that quiz was so hard. Only gor 3 questions right!

Thanks for the quiz though. I learned something from it
 
Old 05-04-2004, 03:44 PM   #6
kooch
Member
 
Registered: Mar 2004
Location: Upstate NY
Distribution: Slackware/YDL
Posts: 77

Rep: Reputation: 15
There are some errors and omissions as I see it. First your code examples don't include headers,functions without prototypes is _bad_. Second you never specify which compiler.
I did the quiz in regard to gcc 3.2.3

Question 1: Answer is actually linker error not compiler error.
Question 5: Doesn't have an answer in the options. The problem is that a and b are out of scope for the function sum. Returning the value returned by printf is fine but _not_ what would be logically intended.

I got 9 out of 10. I missed #5 but I can't feel bad about that since there wasn't a right answer. Now that I look back at it I should have chosen 302. The answer marked as being correct...even though it's even further from correct than the compiler error option.

I'm not trying to troll. You guys _do_ peer review these before posting them right?
 
Old 05-05-2004, 09:21 AM   #7
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
If I remember right, wasn't 5 the one that first printed out 10 + 20 (thus printing 30), then return the value from that printf (which would be 2 since 2 characters were printed), and then it prints that return value. (Thus 302 would be printed, assuming there was no \n after printing 10+20.)

I missed a few of them just because I didn't look at the code close enough, and I wanted to kick myself. Like on number 2 with the extern int i... I didn't see i being defined below that until after I was done and got the answers back. That last one, I didn't even really try. I was at work, and didn't want to take the time to try and figure it out right then.
 
Old 05-05-2004, 11:38 AM   #8
kooch
Member
 
Registered: Mar 2004
Location: Upstate NY
Distribution: Slackware/YDL
Posts: 77

Rep: Reputation: 15
On number 5.

The function called is something like

int sum(int x, int y){
return(printf("%d",a+b));
}

So it gives a compiler error(a and b are not in scope). If it was written as I suppose it was intended, using x + y as the 2nd argument to printf then 302 would be the answer.
 
Old 05-05-2004, 02:11 PM   #9
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Ahhh... yeah, I must have missed that. Oh well.
 
Old 05-07-2004, 02:03 PM   #10
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 10,606

Rep: Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652
Part II of this quiz has been posted. Thanks Thomas.

--jeremy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Quiz? neilcpp LQ Suggestions & Feedback 9 03-08-2004 10:51 PM
New Quiz Posted jeremy General 1 12-09-2003 02:57 AM
New Quiz - vi jeremy Programming 5 11-26-2003 11:39 AM
New Quiz Posted jeremy LQ Suggestions & Feedback 9 03-06-2003 11:17 PM
quiz nautilus_1987 LQ Suggestions & Feedback 12 09-21-2002 10:35 AM


All times are GMT -5. The time now is 04:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration