CSE240 Midterm (QUIZ QUESTIONS)

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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

Contextual

What programming language characteristics impact the readability of the programs written in this language?

Control Structures, Data Structures, Syntax Design

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

It is an or statement. Choose one of the options

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?

It prints: dbu

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

It prints: this is a string

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

One compiler for all machines

Multiple pointers can reference the same objects

TRUE

Sort orthogonality 1 and sort orthogonality 2 implies compositional orthogonality.

TRUE

There was an early focus on efficiency due to early programmable computers being themselves fairly inefficient being limited in power and storage.

TRUE

When evaluating a programming language the category Efficiency describes:

The 'first concern' historically. Concerned with how fast the code compiles and run

Given the declaration: char a[] = "Hello"; char *p = a, *q; what operations are valid syntactically?

*q = *(&a[0]); & q = &(*p);

Which statements indicate why it is important to understand dynamic multi-dimensional arrays as "arrays of arrays"?

-This is the only way to create "ragged or jagged" arrays in C/C++. It might be wise to keep a parallel array of each row's size. -Dynamic allocation requires multiple pointers and each pointer can 'point' to it's own array -If we get that each row is an independent array, it makes the idea of passing single rows or other subsections of the multi-dimensional array to functions easier. -Each row is independently created at run-time

Given the following code, what is the expected value for y? #include <stdio.h> #define func(x, y) (x > y) ? y : x int main() { int x = 10; int y = 9; int z = func(++x, y++); }

11

What's the size of this struct? struct record4 { int a; int c; float e; char b; char d; };

16

What's the size of this struct? struct record3 { int a; char b; int c ; char d; float e; };

20

What is the size of this struct? struct record1 { double x; char p[10]; char c; int a; };

24

What is the size of this struct? struct record1 { char p[10]; double x; char c; int a; };

32

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

<char> ::= a | b | c | ... | s | ... | x | y | z <identifier> ::= <char> | <char> <identifer> No - there is an underscore in the identifier name that cannot be generated.

von Neumann Architecture is:

A state based programming structure which loads and interprets instructions from memory into action

What is a good rule of thumb for sizing a Struct in C/C++ assuming that the Struct is optimally set up?

Count all the bytes of the data in the struct. Find the nearest power of 2, 4 or 8 based on the largest Data Type in your struct. If the total number of bytes is larger than that power, then the struct will be the next power in size.

Dynamically allocated data/objects/etc. are created and exist on the Stack part of RAM

FALSE

Reliability speaks to how easily a programmer can express themselves reliably within the language

FALSE

This quote: "When piloting a helicopter - changing speed can/will change your direction and possibly vice versa" Demonstrates that changing speed and/or direction is Orthogonal

FALSE

When creating a multi-dimensional array during compile time (on stack RAM) it is possible to create a "ragged array" - which is a multi-row array where the rows are not the same length.

FALSE

When creating a multi-dimensional array dynamically in C/C++ the Memory Manager will go to great pains to make sure the array is completely contiguous with each row followed immediately by another row in the array. The goal is to keep all the data together in memory rather than "wherever it fits."

FALSE

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 similar syntaxes and structures.

FALSE

Why does the datatype of the pointer matter? Select all that apply

If I dereference a pointer, the data type informs how many bytes are going to be interpreted and how to interpret them When we do pointer arithmetic, the number of bytes the address changes is based on data type The data types have rules about addressing the pointer needs to work within those rules

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

Interpretation

Macros-Processing takes place during which phase?

Pre-processing

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

Removing Goto statement from the language.

If I have set of commands S1 that describe data types in my language and a set of commands S2 that describe creation of variables: S1: int, decimal, bool S2: <type> <name>, <type> <name> = <value>, constant <type> <name> = <value> The set S3: int <name>, int <name> = <value>, constant int <name> = <value> -- demonstrates what kind of orthogonality?

SORT ORTHOGONALITY

Orthogonality...

Sort = One-to-Many, Compositional = Many-to-Many, Number = general lack of restrictions in reproducing the features of your code

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

Syntactically correct, but contextually incorrect.

A programming languages can be broken down into four structural layers. Identify these layers.

Syntax, Semantic, Contextual,

All pointers are the same size and that size is dependent on the architecture of the processor.

TRUE

Autocode and FORTRAN are considered to be the first high-level programming languages

TRUE

C/C++ is "perfectly happy" to allow the programmer to walk outside the bounds of an array. An error can/will eventually occur when you interact with memory that the Memory Manager has reserved.

TRUE

Given: Very Simple Programming Language (VSPL) <char> ::= a | b | c | ... | z | 0 | 1 | ... | 9 <operator> ::= + | - | * | / | % | < | > | == | >= | <= <variable> ::= <char> | <char> <variable> <expr> ::= <variable> <operator> <variable> | ( <expr> ) <operator> ( <expr> ) <assign> ::= <variable> = <expr>; <statements> ::= <assign> | <assign> <statements> The following is valid: 2sum = 2+3;

TRUE

Given: Very Simple Programming Language (VSPL) <char> ::= a | b | c | ... | z | 0 | 1 | ... | 9 <operator> ::= + | - | * | / | % | < | > | == | >= | <= <variable> ::= <char> | <char> <variable> <expr> ::= <variable> <operator> <variable> | ( <expr> ) <operator> ( <expr> ) <assign> ::= <variable> = <expr>; <statements> ::= <assign> | <assign> <statements> The following is valid: a = x + y; b = s * t; c = w + v;

TRUE

Given: Very Simple Programming Language (VSPL) <char> ::= a | b | c | ... | z | 0 | 1 | ... | 9 <operator> ::= + | - | * | / | % | < | > | == | >= | <= <variable> ::= <char> | <char> <variable> <expr> ::= <variable> <operator> <variable> | ( <expr> ) <operator> ( <expr> ) <assign> ::= <variable> = <expr>; <statements> ::= <assign> | <assign> <statements> The following is valid: myvar = (x + y) * (a - c);

TRUE

Learning the concepts, logic and problem solving of programming unlocks our ability to learn new languages

TRUE

When evaluating a programming language the category Writeability describes:

This concept is concerned with the actual production of code and the ability of the programmer to easily use the language... syntax, abstraction, expressivity

When evaluating a programming language the category Reliability describes:

This concept is concerned with the internal safety and consistency of the language ... type checking, exceptions, etc.

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

Web is the computing platform

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

a longer machine code but with shorter execution time.

What type of value are stored within a pointer type?

an integer value, which represents the address.

Which of the following types is a C++ type, but NOT a C type?

bool

In C++, what function can be used to input a string with spaces?

cin.getline(...);

Event-driven computing paradigm is to

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

Event-driven computing paradigm is to....

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

If I dynamically allocate a 1D array in C++ ... What command do I use to release the memory?

delete[]

What is a feature of object-oriented computing?

encapsulation of states

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

functional

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

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

What programming paradigm does Fortran belong to?

imperative

The imperative programming paradigm is popular and is a part of object-oriented computing paradigm, because it ____ (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.

Given the following code char a[2][3] = { { 'c', 'a', 't'}, { 'd', 'o', 'g'} }; int i, j; for (i = 0; i<2 ; i++) { for (j = 0; j<3; j++) printf("%c", a[i][j]); } What will happen?

it prints: catdog

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

logic

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

pointer type and unsigned int

During compilation, linker is used for ___________________.

resolving external references (bring in code from other libraries).

In the C-Style input function scanf("%d", &i); What does the character "&" mean?

scanf takes the address of an variable as its parameter.

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

semantic error

Assume a variable is declared in a block of code within a pair of curly braces. The scope of the variable ______

starts from its declaration point and extends to the end of the block.

Which command will have a loop when expressed in a syntax graph?

switch

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

to allow functions to return different types of values


Set pelajaran terkait

File System and File Management Terms

View Set

Certified Wireless Technology Administrator - Chapter 11 - Performing an RF Wireless LAN Site Survey

View Set

fundamentals NCLEX Style Questions practice a

View Set