CSE240

Ace your homework & exams now with Quizwiz!

pointer type and unsigned int

"What data types in C have the same data range, assuming that the computer used is a 32-bit computer?"

macro

Which implementation of a function has potentially the best performance in terms of execution speed?

Java

Which language will report a compilation error for the following snippet of code? int i = 3; double n, j = 3.0; n = i + j;

a[0] = 'h';

Which of the following C assignment statement (assign a value to a variable at the semantic level) will NOT cause a compilation error? Assume the array has been declared as: char a[5];

Semantics

Which of the following cannot be checked by an imperative or object-oriented compiler. Select all that applies.

Keep the character type variables together

Which of the following coding practices can lead to a higher memory efficiency (use fewer padding bytes) in defining a structure?

Number Orthogonality

Which of the following orthogonality describe this example: If a block allows one statement, it should allow zero or more statments within that same block

Each name in a program has a single type associated with it. Type errors are always reported.

Which of the following statements are correct if a language is strongly typed. Select all that apply.

A structure type of variable cannot be as the actual parameter for call-by-value

Which of the following statements is true?

call-by-value

Which parameter passing mechanism does not have side-effects?

An unformatted input can read the newline character left from the previous input operation.

Why do we need to flush the input buffer?

True

(True or False) Sort orthogonality 1 and sort orthogonality 2 implies compositional orthogonality.

Syntactic, semantic, contextual

A computer program can be broken down into several structural layers. Which of the followings belong to these structural layers. Select all that applies.

the values allowed. the operations allowed.

A data type is defined by (Select all answers that apply)

an in-line function

A final method in Java defines

80 60 10

A pointer variable can take the address of a memory location as its value. Read the given program. Answer the following three questions. 1.The output of the 1st printf statement is - 2. The output of the 2nd printf statement is - 3.The output of the 3rd printf statement is -

Scope. Type.

A variable declaration can involve the following attributes: (Select all answers that apply)

The users behavior

Amazon's shopping recommendation list is based on

a longer machine code but with shorter execution time.

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, ______

return the memory held by x to the free memory pool.

Assume pointer variable p points to node x of a linked list, and node x's next pointer points to node y. What does free(p) operation mean?

0 the address of a terminal code

Assume that the search function of a linked list is specified by struct Terminal* search(); What values can the search function return? Select all correct answers.

40

Assume this is a 32-bit environment, given a declaration: int a[10]; What is the size (in bytes) of the entire array

4

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]; struct Terminal* next; } x;

Readability

Because of hardware constraints, early programming languages emphasized

No - there is an underscore in the identifier name that cannot be generated.

Can the identifier "base_variable" be created from the following BNF ruleset?

680

Consider the following snippet of code in a 32-bit computer. #define max 10 struct contact { char name[30]; char email[30]; int phone; }; struct contact A[max]; What is the size of the entire array A in bytes?

scanf("%s", contactbook[tail].name);

Consider the following snippet of code in a 32-bit computer. #define max 10 struct contact { char name[30]; char email[30]; int phone; }; struct contact A[max]; int tail = 0; Which statement can read a name into the name field of the structure?

64

Consider the following snippet of code in a 32-bit computer. #define max 10 struct contact { char name[30]; char email[30]; int phone; }; struct contact A[max]; What is the size of the entire array A in bytes?

scanf("%d", &contactbook[tail].phone);

Consider the following snippet of code in a 32-bit computer. #define max 10 struct contact { char name[30]; char email[30]; int phone; }; struct contact A[max]; int tail = 0; Which statement can read a phone number into the phone field of the structure?

64

Consider the following snippet of code in a 32-bit computer. struct contact { char name[30]; char email[30]; int phone; } x; What is the size of variable x in bytes?

68

Consider the following snippet of code in a 32-bit computer. struct contact { char name[30]; int phone; char email[30]; } x; What is the size of variable x in bytes?

More than two machine instructions

Converting an integer value 5 to a float number 5.0 takes

Resolving external references (bring in code form other libraries)

During compilation, linker is used for ___________________.

define a set of events and write an event handler for each event.

Event-driven computing paradigm is to

casting

Explicit type conversion is commonly refer to as __________ .

Y A

For the following BNF ruleset, which are terminal symbols? Select all that apply. <char> ::= a | b | c | ... | x | y | z <identifier> ::= <char> | <char> <identifier>

&a[0] a

Given a C declaration: char a[] = "Hello World"; What can be used as the initial address of array a[]? Select all correct answers.

12

Given a declaration: char a[] = "Hello World"; What is the size (in bytes) of the array a[]?

It prints: this is a string

Given the following code char *p = "hello", *s = "this is a string"; p = s; printf("%s\n", p); What will happen?

A run time error may occur at this line: strcpy(p, s);

Given the following code char *p = "hello", *s = "this is a string"; strcpy(p, s); printf("%s\n", p); What will happen?

It prints: carbike

Given the following code char a[2][4] = { { 'c', 'a', 'r', 'b' }, { 'i', 'k', 'e', '\0' } }; char *p = &a[0][0]; while (*p != '\0') { printf("%c", *p); p++; } What will happen?

It prints: dbu

Given the following code char a[] = {'c', 'a', 't', '\0'}; char *p = a; while (*p != 0) { *p = *p + 1; printf("%c", *(p++)); } What will happen?

Both char a1[size1] and char a2[size2];

Given the following definition and declarations: #define size1 10 const int size2 = 20; char a1[size1]; char a2[size2]; which line of code can cause a compilation error?

both char a1[size1] and char a2[size2];

Given the following definition and declarations: #define size1 10 const int size2 = 20; char a1[size1]; char a2[size2]; which line of code can cause a compilation error?

2 3

Given the following snippet of code, answer the following two questions based on the code: typedef enum {red, amber, green} traffic_light; traffic_light x = red, y = green; while (x != y) { x++; } y++; printf("x = %d, y = %d", x, y); What value will be printed for variable x? Please choose: What value will be printed for variable y? Please choose:

p->next = head; head = p;

Given the information below, how do you insert a new node, p, to the beginning of a linked-list. Assume head is pointing to the first node in the linked-list. struct Terminal { char name[30]; char location[32]; struct Terminal* next; } *head, *p;

x->name;

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]; struct Terminal* next; } *x;

x = head; while(x != NULL) { printf("%s - %s", x->name, x->location); x = x->next; }

Given the information below, which of the following snippet of C code 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]; struct Terminal* next; } *head, *x;

head = null;

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]; struct Terminal* next; } *head, *p, *q; p = (struct contact *) malloc(sizeof(struct contact)); ... p->next = head->next; head->next = p; Assume that you want to delete the entire linked list pointed to by head. Which of the following deletion operation will cause the most garbage of memory?

call-by-alias

Given the snippet of codes, identify the passing mechanism used for y (in func). void func(int *x, int &y) { *x = *x + y; y = 2; }

Syntactically correct, but contextually incorrect.

Given this snippet of code in C, char alpha = 'a'; float numeric = alpha + 10; which of the following statement is correct:

1000

Given this snippet of code, what is the value of x after executing the last statement? int x = 10, *y, **z; y = &x; z = &y; **z = 1000;

100

Given this snippet of code, what is the value of x after executing the last statement? int x = 10, *y; y = &x; *y = 100; y = y + 1;

10

Given this snippet of code, what is the value of x after executing the last statement? int x = 10, *y; y = &x; y = y + 1; *y = 100;

call-by-address

Given this snippet of codes, identify the passing mechanism used for x (in func). void func(int *x, int y){ *x = *x + y; y = 2;}

Call-by-value

Given this snippet of codes, identify the passing mechanism used for y (in func). void func(int *x, int y) { *x = *x + y; y = 2; }

x: 20, y: 10

Given this snippet of codes, what is the expected output? void func(int *x, int y) { *x = *x + y; x = 10; } void main() { int x = 10, y = 10; func(&x, y); printf("x: %d, y: %d", x, y); }

more than 26

How many different identifiers can the following BNF ruleset generate?

semantic error

If a program contains an error that divides a number by zero at the execution time. This error is a

Binary file

If we want to store an array of structures into a disk file, what file type should we choose?

Interpretation

If you like to see accurate debugging information, which of the following program processing would you recommend?

Coercion

Implicit type conversion is commonly refer to as __________ .

fgets();

In C, what function can be used for inputting a string containing spaces?

Variable size (number of bytes) Variable scope Variable type

In a given programming and execution environment, a variable declaration in C binds a name to a memory location. What else are also determined in declaration? Select all that apply.

Web is the computing platform

In contrast to Web 1.0, what is the key function of Web 2.0?

C

In the following pseudo code, which programming language allows the mixed use of data types? int i = 1; char c = 'a'; //declaration and initialization c = c + i; //execution of an assignment statement

Semantic

In the layers of programming language structure, which layer performs type checking?

Registers

In the memory hierarchy of a computer system, which type of memory is the fastest one?

Two Step Translation with Intermediate Code -- (Compilation + Interpretation)

Java uses which of the following program processing?

Pre-processing

Macros-Processing in C takes place during which phase?

Imperative

Stored Program Concept (von Neumann machine) is one of the most fundamental concepts in computer science. What programming paradigm most closely follows this concept?

The dynamic semantics of programs under execution??????

The contextual structure of a programming language defines

Return type Parameter types Function name

The forward declaration of a function requires: (Select all answers that apply)

is based on computer organization and thus is efficient to execute on hardware. matches the culture of doing things by following the step-wise instructions.

The imperative programming paradigm is popular and is a part of object-oriented computing paradigm, because it ____ (Select all answers that apply).

reduce the types of control structures

The main idea of structured programming is to

input leaves a character in the file buffer.

The reason that we need to call fflush() or cin.ignore() is because the previous

Disk access speed is low, but large blocks of data can be read from and written to the disk.

The reason that we use a buffer between the disk and the memory is _______

contextual

Type checking happens during compilation phase, it reinforces which of the following structural layer?

const x = 5;

What C/C++ constant variable can potentially be modified during the execution?

logic

What computing paradigm can solve a problem by describing the requirements, without writing code in a step-wise fashion to solve the problem.

functional

What computing paradigm enforces stateless (no variable allowed) programming?

It is an "or" operation. Choose one of the options.

What does the | (pipe) symbol in a BNF rule mean?

Readability

What factor is generally considered more important in modern programming language design?

A macro

What is "func" in this C program example? #include <stdio.h> #define func(x, y) (x > y) ? y : x int main() { int x = 10; int y = 9; int z = func(x, y); }

to allow a function to return different types of values

What is NOT the purpose (functionality) of the forward declaration (prototype)?

Encapsulation of States

What is a feature of object-oriented computing?

Call-by-alias involves one variable only, while call-by-address involves two variables.

What is the difference between call-by-address and call-by-alias?

The total length of the list must be determined in advance.

What is the main problem with using an array of structures to store data records such as contact list?

One compiler for all machines

What is the main reason of applying two-step translation of high level programming language?

Removing Goto statement from the language.

What is the major improvement of structured programming languages over the earlier programming languages?

pointers

What key feature of programming languages is supported by C++, but not by Java?

source item size destination number of items

What parameters are required when performing file operations fread and fwrite? Select all that apply.

Scheme Prolog

What programming languages better prepare you for leaning the concepts of database query languages such as SQL and LINQ?

A loop to free each node in the FTB list.

When an item is deleted from Amazon's catalog list, we need to delete the FBT linked list using

Between a formatted input and an unformatted input

When do we need to use fflush() or cin.ignore()?

When the file operation fopen is performed.

When will the buffer be created?

Outside all classes

Where is the main() function located in a C++ program?

for ( <init-expr>; <test-expr>; <increment-expr> ) {<statements>} while (condition) do {statements;} If-then-else

Which commands (constructs) do NOT have a loop when expressed in syntax graphs? Select all that apply


Related study sets

CH 43: assessment of Renal and Urinary Tract Functions

View Set

Pharm Chapter 49 - Drugs that treat Anemia

View Set

Chapter 1: Internal Combustion Engines

View Set

IP Chapter 3: International Relations Theories

View Set

Professional Use of Electronic Media

View Set

Lecture 1a/1b: Introduction and Motor Control

View Set