Question

C Programming Quiz

Asked by: cprogramm

1.      The while looping structure can be used in a C program __________.
      A) when the number of repetitions is known in advance.
B) as a pre-test counting controlled loop.
C) as a pre-test conditional controlled loop.
D) all of the above

2.      An infinite loop in a C program can be created in a for looping structure if __________.
      A) no statements exist within the loop.
B) the condition is false before the loop is executed.
C) the control variable is incorrectly modified within the loop.
D) none of the above

3.      How many times will the following loop execute?
initialize ageCounter to 0
while ageCounter is less than or equal to 4
  input inputData
  set testValue to equal to inputData times 1.44
  increment ageCounter by 1
end while
      A) 4
B) 5
C) 6
D) the loop will execute indefinitely

4.      Which of the following is a true statement?
      A) When coding a looping structure it is conventional to indent the statements within the body of the loop.
B) Counter controlled loops (for loops) cannot be nested.
C) Infinite loops are never used in the event-driven programming paradigm.
D) Looping is NOT one of the fundamental programming constructs.

5.      The C programming language provides support for __________ and __________ looping structures only.
      A) for, while
B) for, do-while
C) Pre-Test, Post-Test

6.      The following C coded for statement is an example of __________.
for(;;) {
  printf("Hello class!\n");
}
      A) a syntax error
B) an infinite loop
C) nothing; theres no such construct in C
D) None of the above

7.      In C the for and while loops are examples of pre-test looping structures.
      T) True
F) False

8.      Identify the counter variable in the following loop:
input currentBalance
set interest to 0
set year to 1
read maxYearsAccumulation from Database
while year is less than maxYearsAccumulation
  increment year by 1
  set interest to interest + 0.02 * currentBalance
  set currentBalance to currentBalance * 1.02
  display currentBalance
end while
      A) year
B) yearsAccumulation
C) interest
D) currentBalance

9.      What kind of looping structure is more appropriate in order to implement repetition in the following requirement?
Currency Conversion Program III should allow the user to enter a main menu option, which is error checked as a valid entry, and then proceed with the functionality provided by Currency Conversion Program II. If on the other hand the users choice is invalid, the program should allow the user to reenter a new main menu option which is checked again for validity.
      A) if-then-else
B) switch/case
C) for
D) while or do/while

10.      Which pairs of statements are equivalent?
      A) j++; and j += 1;
B) ++j; and j = j + 1;
C) j += 1; with j = j + 1;
D) All of the above

11.      Which of the following is NOT a true statement?
      A) An array is an arrangement of related values as a block in memory.
B) An array can store values of different data type.
C) Arrays can have more than one dimension.
D) Arrays in C are zero-based.

12.      The number of elements in a single-dimensional array is called the __________ of the array.
      A) width
B) height
C) size
D) depth

13.      All the individual elements of an array have the same __________.
      A) name
B) subscript (index)
C) memory location
D) value

14.      The second element of a zero-based single-dimensional array named price can be referenced by:
      A) price[0]
B) price[2]
C) price2
D) price[1]

15.      What will be the value stored in the third element of myArray once the following C fragment is executed?
myArray[0] = 2;
for(i = 1; i < 4; i++) {
  myArray[i] = myArray[i-1] + 1;
}
      A) 3
B) 4
C) 5
D) 6

16.      If we assume the C declaration int myArray[4], the statement myArray[4]=2; __________.
      A) will initialize the last array element to 2.
B) will be flagged as a syntax error.
C) will produce a bug (semantic error).
D) will have no effect.

17.      Character strings in C must be handled as single-dimensional arrays of char data type.
      T) True
F) False

18.      Which of the following statements is true?
      A) Arrays in C are zero-based.
B) Only for loops can be used in order to iterate over all the elements of an array.
C) An array can store values of different data type.
D) All of above

19.      Assuming no user defined definitions, which of the following is a valid C declaration for a 10-character string variable named title?
      A) char title[11];
B) string title [10];
C) char title [10];
D) char10 title;

20.      In a C double-dimensional array named ChessBoard the statement ChessBoard[5][9] refers to:
      A) The 9-th element of the 5-th row.
B) The 10-th element of the 6-th row.
C) The 5-th element of the 9-th row.
D) The 6-th element of the 10-th row.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-09-08 at 12:56:41ID24716062
Tags

C programming Quiz

Topic

C Programming Language

Participating Experts
1
Points
500
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. INDENTATION
    MORE INFORMATION ABOUT INDENTATION IN c++. Enough to write on the topic.
  2. printf
    In my compiler package there is a directory called include where all the header files are included.. Isn't there supposed to be a source file for every header file where functions are defined? I can't find anywhere the source files... for example I would be interested in see...
  3. printf()
    Hi, What is printf()? If it is a function how it will work for different parameters in c? bye basavaraj
  4. printf()
    Hello experts, For the printf function to work we have to include the <stdio.h> library. But when i look into the library i find only the interface for that function. Where is the actual library linked from? thanx, teena
  5. printf
    can anyone explain how printf works. is it's output implementation dependent? and also kindly explain the output for the following code. # include <stdio.h> void main() { int i=10; printf ("%d %d %d",i,++i,++i); } i got 12 12 11 i don't understan...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Infinity08Posted on 2009-09-08 at 13:01:16ID: 25285609

As before, could you post your answers, so we can check them for you ?

 

by: cprogrammPosted on 2009-09-08 at 13:07:24ID: 25285665

KDO:
I am not sure what you are asking for? This is for me to learn as am a beginner in C.

 

by: cprogrammPosted on 2009-09-08 at 13:07:38ID: 25285671

Will do Infinity.

 

by: cprogrammPosted on 2009-09-09 at 15:00:31ID: 25295976

Answers that i know for quiz are: I know some of the answers but some i do not know but i tried my best. Please let me know what you think.
1.D
2.D
3.B
4.A
5.C
6.B
7.T
8.A
9.B
10.D
11.B
12.C
13.C
14.D
15.B
16.C
17.T
18.B
19.B
20.A

 

by: Infinity08Posted on 2009-09-09 at 23:38:51ID: 25297793

>> 1.D

Technically, that's correct (and I'd answer it too). But I think they had a different answer in mind - without adding any other code, how would you describe a while loop (using one of A, B or C) ?

>> 2.D

You could create an infinite loop like this for example :

        for (i = 0; i < 10; ++i) {
            --i;
        }

This corresponds to one of the 3 other options.

>> 3.B

Correct.

>> 4.A

Indeed.

>> 5.C

Technically, none of the options are right (using break and continue, you can still perform the test anywhere you please). But one of them is more right than the others, and that's indeed C.

>> 6.B

Yes.

>> 7.T

Correct.

>> 8.A

Right.

>> 9.B

The emphasis of the question is on the looping behavior of the code ... So, which answer would suit best ?

>> 10.D

Ok.

>> 11.B

Correct.

>> 12.C

I'd use that term too :)

>> 13.C

This one is tricky. But it's definitely not C, since different items in an array have different (consecutive) memory addresses.

>> 14.D

Yes. Since array indexes are 0 based (first item is at index 0).

>> 15.B

Ok.

>> 16.C

Definitely. It will perform an out-of-bounds access on the array, and overwrite a memory location not owned by it. Anything can happen after that, and that's a definite bug :)

>> 17.T

Indeed. Because that's what they are.

>> 18.B

You can use a while loop or any other type of loop to loop over all items in an array, so it's not B. But there is another option that is true.

>> 19.B

No. There's no 'string' type in C. C strings are basically arrays of char (see question 17). Remember to make room for the '\0' terminator at the end of the string !

>> 20.A

No. Remember that array indexes are 0-based.

 

by: cprogrammPosted on 2009-09-10 at 07:47:36ID: 25300755

Infinity here are my revised answers:
1. A
2. C
9. D
13. B
18.A
19. A
20.B


Please let me know what you think.

 

by: Infinity08Posted on 2009-09-10 at 08:02:17ID: 25300914

>> 1. A

Is that what a while loop is best at ? Consider the three main types of loops : the for loop, the while loop, and the do-while loop. Each of these corresponds to A, B or C. How would you classify them ?

>> 2. C

Good.

>> 9. D

That would be my choice too :)

>> 13. B

The index will always be different for the different items in the array. So it's not B. There's not many choices left ;)

>> 18.A

Indeed.

>> 19. A

Indeed. An array of 11 characters ... 10 for the string data, and one more for the '\0' terminator.

>> 20.B

That's it :)

 

by: cprogrammPosted on 2009-09-10 at 09:03:43ID: 25301558

Infinity08,
Folowing are my next try.
1.  The answer should be either B or C for sure. I know WHILE is used for  Pre test condition, i would go for C. What do you think?
13. There are 2 opetions left. It could be either A or D. I would go with D. What you think for this choice.

Thanks,

 

by: Infinity08Posted on 2009-09-10 at 09:19:39ID: 25301726

>> 1.  The answer should be either B or C for sure. I know WHILE is used for  Pre test condition, i would go for C. What do you think?

Sounds good.

It's pre-test, because the loop condition is checked at the start of each iteration, and it's conditional controlled, because the loop depends on a condition to decide whether it will continue or not.


>> 13. There are 2 opetions left. It could be either A or D. I would go with D. What you think for this choice.

Different array items can have different values (and they usually will). So, no that's not it. It's A I'm afraid, since the array name doesn't change, and stays the same for each of the items :

        array_name[0]
        array_name[1]
        array_name[2]
        ...
        array_name[n-1]

I told you it was tricky ;)

 

by: cprogrammPosted on 2009-09-10 at 10:30:35ID: 25302426

Thank you Infinity. Thanks for your help and you been very help ful and hope you will help me in upcoming quiz.thanks

 

by: Infinity08Posted on 2009-09-10 at 11:56:55ID: 25303165

Glad to be of assistance :)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...