Top-Rated Free Essay
Preview

C Program

Good Essays
767 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
C Program
Directions 1. Some of the questions/programs are required to be typed, complied, run and then observed. 2. If possible try experimenting with concepts revealed by each question. 3. There are 20 objective type questions on ANSI C. PART - A

With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed? a.) b.) c.) d.) unalloc() dealloc() release() free()

What will print when the sample code above is executed? a.) b.) c.) d.) y= y= Compiler Error y=

The definition of a above explicitly initializes its first four elements. Which one of the following describes how the compiler treats the remaining four elements? a.) The remaining elements are initialized to zero(0). b.) It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized. c.) As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively. d.) They are left in an uninitialized state; their values cannot be relied upon.

Which one of the following functions is the correct choice for moving blocks of binary data that are of arbitrary size and position in memory? a.) b.) c.) d.) memcpy() memset() strcpy() memmove()

What value does testarray[2][1][0] in the sample code above contain? a.) b.) c.) d.) 5 7 9 11

Which one of the following provides conceptual support for function calls? a.) b.) c.) d.) The system stack The data segment The text segment The heap

What does y in the sample code above equal? a.) -3 b.) 4 c.) 4 + sizeof ( int ) d.) 4 * sizeof ( int )

What will the above sample code produce when executed? a.) 1, 2, 3, 4, 5, 5, b.) 4, 3, 2, 1, 0, 0, c.) 5, 4, 3, 2, 1, 0, d.) 0, 0, 1, 2, 3, 4,

What does the operation shown above produce? a.) 1 b.) 6 c.) 8 d.) 14

Referring to the sample above, what is MAX_NUM? a.) MAX_NUM is an integer variable. b.) MAX_NUM is a linker constant. c.) MAX_NUM is a preprocessor macro. d.) MAX_NUM is an integer constant.

Referring to the sample code above, what value will the variable completed? a.) 0 b.) 1 c.) 2 d.) 3

have when

What string does ptr point to in the sample code above? a.) fg b.) efg c.) defg d.) cdefg

Which one of the following is a true statement about pointers?

a.) Pointer arithmetic is permitted on pointers of any type. b.) A pointer of type void * can be used to directly examine or modify an object of any type. c.) Standard C mandates a minimum of four levels of indirection accessible through a pointer. d.) Pointers may be used to simulate call-by-reference.

Which one of the following functions returns the string representation from a pointer to a time_t value? a.) b.) c.) d.) localtime gmtime asctime ctime

Which one of the following variable names is NOT valid? a.) b.) c.) d.) go_cart__ go4it 4thseason _what

In terms of code generation, how do the two definitions of buf, both presented above, differ? a.) The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not. b.) The first definition is not suitable for usage as an argument to a function call; the second definition is. c.) The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal. d.) They do not differ -- they are functionally equivalent.

In a C expression, how is a logical AND represented?

a.) b.) c.) d.)

|| .AND. && .AND

What will print when the sample code above is executed? a.) b.) c.) d.) z=0.00 z=1.00 z=1.50 z=2.00

What is wrong with the above code (assuming the call to malloc does not fail)? a.) b.) c.) d.) There will be a memory overwrite. There will be a memory leak. There will be a segmentation fault. It will not compile.

How is enum used to define the values of the American coins listed above? a.) enum coin {(penny,1), (nickel,5), (dime,10), (quarter,25)}; b.) enum coin ({penny,1}, {nickel,5}, {dime,10}, {quarter,25});

c.) enum coin {penny=1,nickel=5,dime=10,quarter=25}; d.) enum coin (penny=1,nickel=5,dime=10,quarter=25);

You May Also Find These Documents Helpful

  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    4. Assume the variables result, w, x, y , and z are integers, and that w=5, x=4, y=8, and z=2. What value will be stored in result in each of the following statements?…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CHAPTER3 REVEIW

    • 527 Words
    • 3 Pages

    a. The CPU tells the RAM which address holds the data that the CPU wants to read…

    • 527 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    b. Provides a convenient way to name a set of data for easier operations like…

    • 856 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    PT1420 Chapter 3 Review

    • 1062 Words
    • 8 Pages

    7. because it could be a variable conflict, the global variables are inherited throughout the whole program, so it very well could conflict with others…

    • 1062 Words
    • 8 Pages
    Satisfactory Essays
  • Powerful Essays

    8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total.…

    • 748 Words
    • 3 Pages
    Powerful Essays
  • Satisfactory Essays

    Pt1420 Assignment

    • 1058 Words
    • 5 Pages

    1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it.…

    • 1058 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    Nothing

    • 1097 Words
    • 5 Pages

    B) 1, 2, 3, 4, 5, 6, 7, 8, 9, A D) 1, 2, 3, 4, 5, 6, 7, 8, 9, 11 6)…

    • 1097 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Macro Examples

    • 1120 Words
    • 5 Pages

    7. The If…Then…Else…End If code allows code to be conditionally executed depending on whether a specified logical condition has been met.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    Java Chapter 2 Quiz

    • 2047 Words
    • 9 Pages

    4. The ____ is normally considered the standard output and standard input devices, and usually refer to…

    • 2047 Words
    • 9 Pages
    Powerful Essays
  • Good Essays

    Chapter 8 Quiz

    • 469 Words
    • 2 Pages

    2. What is the term used for the number inside the bracket that specifies the number of values that an array can hold? (Points : 7)…

    • 469 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    /*question number 3*/ Code: void *ptr; myStruct myArray[10]; ptr = myArray; Which of the following is the correct…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Good Essays

    7 and Array

    • 500 Words
    • 2 Pages

    7. When a single array element, such as myArray[2], is passed to a method, the method receives _____.…

    • 500 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    a.x is available to code that is written outside the Sphere class. b.radius is not available to code written outside the Sphere class. c.radius, x, y, and z are called members of the Sphere class. d.z is available to code that is written outside the Sphere class.…

    • 1368 Words
    • 9 Pages
    Satisfactory Essays
  • Better Essays

    Nt1310 Unit 4

    • 3614 Words
    • 15 Pages

    The program is trying to collect the value of a "void" function into an integer variable.…

    • 3614 Words
    • 15 Pages
    Better Essays
  • Powerful Essays

    Parents

    • 21720 Words
    • 87 Pages

    0 6 9 12 -7 1 -1 -2 6 1 2 3 4 5 8…

    • 21720 Words
    • 87 Pages
    Powerful Essays