Top-Rated Free Essay

C Program

Good Essays
Topics:
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

    c ++ program

    • 252 Words
    • 1 Page

    and letters. b. In C++, there is no difference between a reserved word and a pre- 
defined identifier. c. A C++ identifier can start with a digit. d. The operands of the modulus operator must be integers. e. Ifa=4;andb=3;,thenafterthestatementa=b;thevalueofbisstill3. f. In the statement cin >> y;, y can only be an int or a double variable. g. In an output statement, the newline character may be a part of the string. h. The following is a legal C++ program: 
 10. Which of the…

    • 252 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    C++ Programs

    • 716 Words
    • 3 Pages

    EC101A: Computer Systems and Programming Spring Semester: 2010-2011 January 20, 2011 1. Write a program program in C++ to find the square of the numbers from 1 to 10 using : (a) for loop (b) while loop (c) do-while loop The output of the program should be in the following format: Number Square ……… ……… 2. Write a program in C++ that calculates the value of π from the infinite series [pic] Print a table that shows the value of π approximately…

    • 716 Words
    • 3 Pages
    Good Essays
  • Good Essays

    C Program

    • 808 Words
    • 4 Pages

    possible operations, which can be performed with the variable However, we never considered the permanence of a variable or its scope i.e. the portion of the program where the variable is valid or recognized. All these factors are considered with storage classes. In C, variables differ in behavior from those in most of the other languages. A variable in C can have anyone of the four storage classes: 1. Automatic Storage class 2. External Storage class 3. Static Storage class 4. Register…

    • 808 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    C Program

    • 2161 Words
    • 9 Pages

    Code Wizard Start //// //}}NodeBuilder Code Wizard End ////////////////////////////////////////////////////////////////////////////// // File: closedLoopSensor.nc // // // Generated by NodeBuilder Code Wizard Version 3.14.03 // Copyright (c) 2001-2005 Echelon Corporation. All rights reserved. // // ECHELON MAKES NO REPRESENTATION, WARRANTY, OR CONDITION OF // ANY KIND, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE OR IN // ANY COMMUNICATION WITH YOU, INCLUDING, BUT NOT LIMITED TO, //…

    • 2161 Words
    • 9 Pages
    Powerful Essays
  • Good Essays

    89s52 C Program

    • 1000 Words
    • 4 Pages

    Simple C program for 89S52 Here is a very simple but complete example program to blink a LED. Actually it is the source code of the example project that we are going to construct in the next part of the tutorial, but for now it is important to concentrate on the programming to summarize the notions discussed above. ------------------------------------------------- #include <REGX52.h> ------------------------------------------------- #include <math.h>…

    • 1000 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Gauss Program on C++

    • 369 Words
    • 2 Pages

    % Program for Gauss - Seidel Load Flow Analysis % Assumption, Bus 1 is considered as Slack bus. ybus = ybusppg(); % Calling program "ybusppg.m" to get Y-Bus. busdata = busdata6(); % Calling "busdata6.m" for bus data. bus = busdata(:,1); % Bus number. type = busdata(:,2); % Type of Bus 1-Slack, 2-PV, 3-PQ. V = busdata(:,3); % Initial Bus Voltages. th = busdata(:,4); % Initial Bus Voltage Angles. GenMW = busdata(:,5); % PGi, Real…

    • 369 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    | |A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose, C++ provides control structures that serve to specify what has to be done by our program, when and under which circumstances. With the introduction of control structures we are going to have to introduce a new concept: the compound-statement or block. A block is a group of statements which are separated by semicolons (;) like all C++ statements…

    • 283 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Group 1 Write a C++ program or each of the following problems: 1. Write a C++ program to enter a distance in meters and print out its value in kilometers, yards, and miles. (Note: 1 m = 0.001 km = 1.094 yd = 0.0006215 mi). 2. Write a C++ program to enter length and width of a rectangle, compute and print the area and perimeter of the rectangle. Print both rounded to the nearest tenth of a foot. 3. Write a program to compute the cost for carpeting a room. Input should consist of the room length…

    • 631 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Odd-Even Program C++

    • 311 Words
    • 2 Pages

    COMPUTER STUDIES DEPARTMENT OF COMPUTER STUDIES LABORATORY ACTIVITY 3 ODD-EVEN NUMBER IN TURBO C RATINGS LIA G. BANDAHALA 2011 - 11502 MR. IVAN JAMES FERMANEJO INSTRUCTOR I. Aim : * Write a Program to determine whether input number is ODD or EVEN. * Proper demonstration the use of Conditional Statements and Control Statements. II. Tools/Apparatus : Turbo C III. Procedure : A. Common Procedure * Enter the number. Make the coding that…

    • 311 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Btech C Program Lab Notes

    • 3229 Words
    • 13 Pages

    www.jntuworld.com www.jwjobs.net C Programming & Data Structures UNIT-1 Introduction to Computers: A computer system consists of hardware and software. Computer hardware is the collection of physical elements that comprise a computer system. Computer software is a collection of computer programs and related data that provides the instructions for a computer what to do and how to do it. Software refers to one or more computer programs and data held in the storage of the computer for some…

    • 3229 Words
    • 13 Pages
    Good Essays