1
1
ANSWER :_ This concept asks how tied down a language is to a particular platform, can code be
distributed easily and can libraries be made and shared
----------------------------
Autocode and FORTRAN are considered to be the first high-level programming languages.
ANSWER :_ True
----------------------------
There was an early focus on efficiency due to early programmable computers being themselves fairly
inefficent being limited in power and storage.
ANSWER :_ True
----------------------------
With over 500 programming languages in the world, the best way approach to learning languages is
to focus on memorizing syntax and structure. Then learn languages with simimlar syntaxes and
structures.
ANSWER :_ False
----------------------------
What is the major improvement of structured programming languages over the earlier programming
languages?
----------------------------
What programming language characteristics impact the readability of the programs written in this
language?
----------------------------
ANSWER :_ Imperative
----------------------------
----------------------------
ANSWER :_ define a set of events and write an event handler for each event.
----------------------------
ANSWER :_ A state based programming structure which loads and interprets instructions from
memory into action
----------------------------
ANSWER :_ define a set of events and write an event handler for each event.
----------------------------
If your program was designed to print "Hello World" ten (10) times, but during execution, it printed
eleven (11) times. What type of error is it?
----------------------------
----------------------------
For the following BNF ruleset, which are terminal symbols? (Check all that apply.)
ANSWER :_ y, a
----------------------------
Which commands (constructs) do NOT have a loop when expressed in syntax graphs? Select all that
apply
if-then-else
----------------------------
If a program contains an error that divides a number by zero at the execution time. This error is a
----------------------------
Given:
myvar = (x + y) * (a - c);
ANSWER :_ true
----------------------------
Given:
ANSWER :_ True
----------------------------
Given:
a = b + c + d;
ANSWER :_ false
----------------------------
If you like to see accurate debugging information, which of the following program processing would
you recommend?
ANSWER :_ Interpretation
----------------------------
If your application is composed of multiple modules (programs), which of the following program
processing would you recommend?
ANSWER :_ Compilation
----------------------------
What is the main reason of applying two-step translation of high level programming language?
#include <stdio.h>
int main()
int x = 10;
int y = 9;
ANSWER :_ A macro
----------------------------
Assume a function requires 20 lines of machine code and will be called 10 times in the main
program. You can choose to implement it using a function definition or a macro definition.
Compared with the function definition, macro definition will lead the compiler to generate, for the
entire program, ______
----------------------------
#include <stdio.h>
int main()
{
int x = 10;
int y = 9;
ANSWER :_ 10
----------------------------
ANSWER :_ Casting
----------------------------
If a block allows one statement, it should allow zero or more statments within that same block.
----------------------------
In the C-Style input function scanf("%d", &i); What does the character "&" mean?
----------------------------
----------------------------
ANSWER :_ cin.getline(...);
----------------------------
----------------------------
----------------------------
Assume a varible is declared in a block of code within a pair of curly braces. The scope of the variable
ANSWER :_ starts from its declaration point and extends to the end of the block.
----------------------------
Given a C declaration: char a[] = "Hello World"; What can be used as the initial address of array a[]?
Select all correct answers.
ANSWER :_ *a[0]
----------------------------
Given a declaration: char a[] = "Hello World"; What is the size (in bytes) of the array a[]?
ANSWER :_ 12 bytes
----------------------------
Which of the following C assignment statements (assign a value to a variable at the semantic level)
will NOT cause a compilation error?
----------------------------
Which of the following statements will assign the address of the variable int myInt to the pointer
int* myPtr?
----------------------------
Given the following:
ptr1 = ptr1 + 5;
ANSWER :_ 1877212
----------------------------
Which of the following statements will allow me to give the value of 10 to the memory int* myPtr
points to?
----------------------------
'*chPtr' = '*iPtr;'
ANSWER :_ 'x'
----------------------------
ANSWER :_ True
----------------------------
C/C++ has 2 pointer operators, which operator represents the name of the address? (Commonly
refer as l-value.)
----------------------------
Given this snippet of code, what is the value of x after executing the last statement?
y = y + 1;
*y = 100;
ANSWER :_ 10
----------------------------
Given this snippet of code, what is the value of x after executing the last statement?
y = &x;
*y = 100;
ANSWER :_ 100
----------------------------
Given this snippet of code, what is the value of z after executing the last statement?
z = &y;
y = &x;
*y = 100;
----------------------------
A pointer variable can take the address of a memory location as its value. Read the given program.
#include <stdio.h>
main() {
p = &a;
*p = 50;
q = &b;
*q = 70;
r = &p;
**r = 90;
a = 20;
b = 80;
----------------------------
ANSWER :_ Function does not want to modify the value, the value is expensive to copy and NULL is
not valid
----------------------------
ANSWER :_ Function does not want to modify the parameter and the value is easy to copy
----------------------------
ANSWER :_ Function does not want to modify the value, the value is expensive to copy and NULL is
valid
----------------------------
char a[2][4] = { { 'c', 'a', 'r', 'b' }, { 'i', 'k', 'e', '\0' } }; char *p = &a[0][0]; while (*p != '\0') { printf("%c",
*p); p++; }
----------------------------
int i, j;
printf("%c", a[i][j]);
}
ANSWER :_ catdog
----------------------------
#define size1 10
char a1[size1];
char a2[size2];
----------------------------
typedef enum {Sun, Mon, Tue, Wed, Thu, Fri, Sat} days;
while (x != y) { x++; }
y++;
ANSWER :_ x = 6, y = 7
----------------------------
struct contact {
char name[30];
int phone;
char email[30];
} x;
ANSWER :_ 68
----------------------------
ANSWER :_ When the structure contains a word-type variable, such as integer, float, and pointer,
and the total number of bytes is not a multiple of four.
----------------------------
The size (number of bytes) of a structure-type variable can be changed by the following factors.
Select all that apply.
----------------------------
What parameters are required when performing file operations fread and fwrite?
ANSWER :_ Destination
Item Size
Number of Items
Source
----------------------------
----------------------------
The reason that we need to call fflush() or cin.ignore() is because the previous
----------------------------
What values can the search function return? Select all correct answers.
----------------------------
Assume pointer variable p points to node x, and node x's next pointer points to node y. What does
free(p) opeartion mean?
----------------------------
Assume this is a 32-bit environment, what is the size of x? (HINT: Don't forget about padding.)
struct Terminal {
char name[30];
char location[32];
} x;
ANSWER :_ 68 bytes
----------------------------
Given the information below, how will you access the name for a terminal node pointed to by x?
struct Terminal {
char name[30];
char location[32];
} *x;
ANSWER :_ x->name;
----------------------------
Given the information below, which of the following snippet of codes will print every terminal in the
linked-list without any side-effects of changing the state. Assume head is the only reference to the
linked-list and there are more than one terminal in the list.
struct Terminal {
char name[30];
char location[32];
} *head, *x;
ANSWER :_ x = head;
while(x != NULL) {
x = x->next;
----------------------------
Given the information below, which of the following snippet of codes will insert a new node in the
second place in the linked-list. Assume the linked-list contains already at least one node.
struct Terminal {
char name[30];
char location[32];
...
p->next = head->next;
head->next = p;
----------------------------
How do you properly delete the first node of a linked list pointed to by head, assuming that the
linked list is not empty and temp is another pointer of the same type?
head = head->next;
free(temp);
----------------------------
ANSWER :_ size-m problem has been solved by the underlying recursive mechanism, where m < n.
----------------------------
Given this snippet of code, identify what is the stopping condition and return value?
else {
deleteList(node->next);
free(node);
ANSWER :_ deleteList(node->next);
----------------------------
----------------------------
In the hanoi towers function, what part of the code represent step 4: Constructiopn of size-n
problem from size-(n-1) problems?
hanoitowers(1, S, M, D);
hanoitowers(n-1, M, S, D);
----------------------------
If you want to change the insertion sort function with a size-(n-1) problem, as discussed in the
lecture, to a merge sort function, where do you need to make changes?
ANSWER :_ CorrectC.
CorrectD.
In the code code that constructs the solution of size-n problem from the size-m problem.
----------------------------
When inserting a data into a binary search tree, the data should be inserted
ANSWER :_ at the position to keep the entire tree as a binary search tree.
----------------------------
ANSWER :_ O(n)
----------------------------
Consider an array, a linked list, and a binary search tree. Which data structure requires fewest
comparisons in average to search an element stored in the data structure?
----------------------------
How do we include a user-defined library, say myMathLib.h, into a program that uses this library?
----------------------------
What is the key difference between a static variable and a global variable?
----------------------------
If a function calls another function, the local variables in these two functions use the memory from
----------------------------
int x = 5;
int bar(int j) {
int *k = 0, m = 5;
k = &m;
return (j+m);
void main(void) {
i++;
i = bar(i) + x;
ANSWER :_ CorrectB.
CorrectC.
CorrectD.
----------------------------
----------------------------
----------------------------
What is the best way of deleting an array created by "p = new StructType[size];" in C++
ANSWER :_ delete[] p;
----------------------------
What is the best of deleting all the nodes in a binary tree pointed to by the root pointer?
----------------------------
Consider a path from the root to a leaf of a class tree based on the inheritance. Which class has the
most class members?
----------------------------
The semantics of multiple inheritance becomes complex and error prone, if the base classes have
----------------------------
----------------------------
If you want to create a linked list of Container nodes, which can contain Publication node, Book
node, Thesis node, and Report node, what type of pointer should be declared in the Container to
point to all these nodes?
----------------------------
If you declare a pointer to the object of the parent class and use the pointer to access the object of a
child class, you can access
----------------------------
Given the following class definition and the variable declaration: How to initialize id
class employee
char *name;
long id;
class manager {
employee empl;
char* rank;
}x
----------------------------
Assume that Publication is the root class of an inheritance tree. You want to form a linked list of
different publications in the inheritance tree, including Book, Report, Newspaper, etc. What is the
best way to create a linked list using PublListNode and Publication classes?
----------------------------
----------------------------
What type casting mechanism should be used if you want to cast an integer value to a double value?
ANSWER :_ static_cast
----------------------------
ofstream myFile;
myFile.open(myFile);
ANSWER :_ It saves the word Hello into a file in the file system.
----------------------------
ANSWER :_ Correct
Correct
++
Correct
>>
----------------------------
----------------------------
ANSWER :_ catch
----------------------------
In addition to functional programming, what other ideas are originated by John McCarthy?
e-commerce
----------------------------
----------------------------
ANSWER :_ (* 9 (/ (- 4 2) 7))
----------------------------
----------------------------
What data structure is used in Scheme for representing extremely large integers?
ANSWER :_ list
----------------------------
(min (min (car lst) (cadr lst)) (min (caddr lst) (cadddr lst)))
ANSWER :_ 2
----------------------------
(guess 10)
ANSWER :_ Correct
"I'm a number"
----------------------------
----------------------------
----------------------------
One of the major differences between the imperative and functional programming languages is that
the functional programming languages do NOT
ANSWER :_ have side-effect.
----------------------------
What notation requires parentheses in order to correctly define the order of computation?
----------------------------
10 + (5 - 3) + 2 / 4
ANSWER :_ (+ 10 (- 5 3) (/ 2 4))
----------------------------
Given an expression: x1 + x2 + x3 + x4
Which language allows to evaluate the expression in this order: (1) x1 plus x2; (2) x3 plus x4; (3) sum
of ( x1 + x2 ) plus sum of ( x3 + x4 );
ANSWER :_ Scheme
----------------------------
How does Scheme implement the function such as: for (i = 1; i< 100, i++) {sum = sum + i;}
----------------------------
----------------------------
What statements contain non-functional features of Scheme? Select all that apply.
Correct
(display x)
----------------------------
----------------------------
((lambda (x)
((lambda (x y)
(+ x y))
5 (* 7 x)))
3)
----------------------------
Given the Scheme code below, answer the following questions related the Fantastic Four abstract
approach.
(1) What line of code defines the stopping condition and the return value? Choose [Size1]
(2) What line of code contains the size-M problem, where M < N? Choose [SizeM]
(3) What lines of code define the step that construct the solution to size-N problem? Choose
[SizeM_N
ANSWER :_ (1) What line of code defines the stopping condition and the return value? Choose
Correct Line 2
(2) What line of code contains the size-M problem, where M < N? Choose Correct Line 3
(3) What lines of code define the step that construct the solution to size-N problem? Choose Correct
Lines 3 & 4
----------------------------
----------------------------
----------------------------
What statements contain non-functional features of Scheme? Select all that apply.
ANSWER :_ Correct
(begin (write x) x)
Correct
(display x)
----------------------------
ANSWER :_ CorrectB.
----------------------------
((lambda (x)
((lambda (x y)
(+ x y))
5 (* 7 x)))
3)
----------------------------
ANSWER :_ CorrectA.
(1 0 1 0 1 0)
----------------------------
ANSWER :_ Correct
(4 6 8 10 12 14)
----------------------------
----------------------------
----------------------------
ANSWER :_ facts.
rules.
questions.
----------------------------
A goal succeeds, if there are facts (rules) that match or unify the goal. What are required in order for
a goal clause and a fact to unify? Select all that apply.
----------------------------
A fact starts with a relationship followed by a list of arguments. The arguments of a fact
----------------------------
----------------------------
What notation does Prolog use for expressing arithmetic operations?
ANSWER :_ CorrectB.
infix notation
----------------------------
is_dessert(cookie).
is_dessert(ice_cream).
is_dessert(pie).
is_dessert(cheesecake).
is_fruit(strawberry).
is_fruit(apple).
is_fruit(peach).
contains(cookie, chocolate_chips).
contains(pie, apple).
contains(pie, peach).
contains(pie, strawberry).
contains(cheesecake, strawberry).
Which of the following rule can help summarize all desserts that contains fruits:
ANSWER :_ Correct
----------------------------
ANSWER :_ Correct
Error Message
----------------------------
ANSWER :_ CorrectC.
----------------------------
In the following query language statement, which function acts as the filter function?
var myQuery = from b in Books where b.price < 80 orderby b.title select b;
ANSWER :_ C.
where
----------------------------
Which predicate logic matches most closely with this statement? Bill listens to music and the news
ANSWER :_ CorrectC.
----------------------------
A goal succeeds, if there are facts (rules) that match or unify the goal. What are required in order for
a goal clause and a fact to unify? Select all that apply.
ANSWER :_ Correct
their corresponding arguments match.
Correct
Correct
----------------------------
ANSWER :_ Correct
facts.
Correct
rules.
Correct
questions.
----------------------------
A fact starts with a relationship followed by a list of arguments. The arguments of a fact
ANSWER :_ CorrectA.
----------------------------
----------------------------