KDO:
I am not sure what you are asking for? This is for me to learn as am a beginner in C.
Main Topics
Browse All Topics1. 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.
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.
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.
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.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
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.
>> 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.
>> 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 :)
>> 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 ;)
Business Accounts
Answer for Membership
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 ?