COP3223C Final

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

All preprocessor commands begin with what symbol?

#

enum day {sunday = 1, monday, tuesday = 5, wednesday, thursday = 10, friday, saturday}; Given the enumeration definition above, what is the value of saturday?

12

The C preprocessor offers operators to help create macros. Match the operator to its behavior.

\ - a macro is # - converts ## - it permits two

The C Programming language includes predefined macros. They are available for use in programming however, the predefined macros should not be directly modified. Match the predefined macro to its behavior.

_DATE_ - the current date _TIME_ - the current time _FILE_ - this contains the current file name _LINE_ - this contains the current line number _STDC_ - defined as 1

What is the global variable that indicates an error occurred during any function call defined in <error.h> header file?

errno

Two enum names cannot have same value

false

enum state {working, failed}; enum result {failed, passed}; If the above enumerations are in the same scope, this source code would compile with no errors.

false

What function is used to close a file?

fclose()

What function is used to open a file?

fopen()

If errno is the value of 0, what does it indicates regarding the status of the program?

no errors

Match the error handling term to its behavior.

perror() - displays strerror()- returns errno - a global variable stderr - file stream

A preprocessor command must be the first nonblank character.

true

C programming does not provide direct support for error handling

true

Enumeration (or enum) is a user defined data type in C.

true

It is considered good programming practice to use the cast operator whenever type conversions are necessary

true

The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process

true

The keyword 'enum' is used to declare new enumeration types in C

true

The usual arithmetic conversions are not performed for the assignment operators, nor for the logical operators && and ||

true

Type casting is a way to convert a variable from one data type to another data type

true

void integerPromotion() { int i = 17; char c = 'c'; int sum; sum = i + c; printf("Value of sum : %d\n", sum ); } Given the C data types and the concept of integer promotion, the above source code would compile and run without errors.

true

Regarding memory management, match the function to the best definition.

void *calloc(int num, int size); - num elements rayvoid free(void *address); - releases a block void *malloc(int num); - of num bytes and leaves them uninitialized void *realloc(void *address, int newsize); - reallocates

Match the preprocessor commands to their behavior.

#define - used for constants #include - inserts a particular #undef - undefines #ifdef - returns true if macro is defined #ifndef - returns true if macro is not defined #if - tests if a #else - the alternative #elif - #else and #if #endif - ends preprocessor #error - prints error #pragma - issues special

Which of the following is an example of using the cast operator?

(type_name) expression

enum day {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; Given the enumeration definition above, what is the value of Sunday?

0

The C Programming language has functions built in for file access. Match the function to its behavior.

fputc() - writes a character fputs() - writes a string fprintf() - writes a formatted string fgetc() - reads a character fgets() - reads a string fscanf() - reads a formatted string

Regarding file opening, one of the arguments that must be passed is the access mode. Match the access mode to its behavior.

r - opens an existing w - opens a text file for writing a - opens a text file for writing in appending mode r+ - opens a text file for reading and writing only w+ - it first tunicates a+ - the reading will start


Set pelajaran terkait

Chapter 16 Violence and Human Abuse

View Set

Differential Equations True or False

View Set

Sociology Midterm 2 review (Chp 1-6)

View Set

ANT 104 - Revealing Archaeology - Provisioning Society

View Set

Advanced Accounting Chapter 12 Smartbook

View Set