Exam 1 programming

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

Which of the following is true regarding variable definition in C? Select all that apply. - is useful when you are using multiple files - provides assurance to the compiler that there exists a variable with the given type and name - cannot declare a variable multiple times in a C program - has its meaning at the time of compilation only

- is useful when you are using multiple files - provides assurance to the compiler that there exists a variable with the given type and name - has its meaning at the time of compilation only

Which of the following is true regarding a variable in C? Select all that apply. - has a specific type - the data type determines the set of operations that can be applied to the variable - the data type determines the size of the variable -the data type determines the range of values that can be stored -all variables use four bytes of memory -the data type determines the layout of the variable's memory -the data type determines how it can be named

--Has specific type --data type determines the set of operations that can be applied to the variable --The data type determines the size --The data type determines the range of values --The data type determines the layout of the variable's memory

What is the file extension of a C language source code file? .java .c++ .c .cpp

.c

There are multiple formats of an acceptable comment in C, select all that apply. // comment */ comment /* \\ comment /* comment */

// comment and /* comment */

Why is C widely used? Select all that apply. 1. Structured language 2. Object-oriented language 3. It produces inefficient programs 4. It can handle low-level activities 5. It can be compiled on a variety of computer platforms 6. Easy to learn

1. 4. 5. and 6.

When was C first implemented? 1994 1972 1978 1959 - 1961

1972

Given the source code below, how many tokens make up the statement? printf("Hello COP 3223!"); 1 5 3 7

5

runs nearly as fast as which other language? Java Pascal Assembly language FORTRAN

Assembly Language

Which language is C the successor of? B D A J

B

Match the data type to its definition. Basic Types Enumerated types void Derived types Aggregate types

Basic Types- Arithmetic types are further classified into integer and floating point types. Enumerated Types- Used to define variables that can only assign certain discrete integer values. Void- No value is available Derived types- pointer, array, structure, union, Function types Aggregate Types- array and structure

A variable definition must include as a minimum which of the following? Select all that apply. int variableName = 53; Initial value Data type Valid name Assignment operator Semi-colon

Data type, Valid name, Semi-colon

Who developed the C programming language? 1. John Backus 2. Brendan Eich 3. Dennis M. Ritchie 4. Chris Lattner

Dennis Ritchie

Character literals are enclosed in double quotes. True False

False

Regarding keywords in the C programming language and creating identifiers. Keywords are reserved in all lowercase AND all uppercase. True False

False

Regarding whitespace in the C programming language, spaces are required between the operators in the following source code in order to compile, run, and provide the correct output. int sum=2+3/2-12*15; True False

False

Which of the following are the parts of a floating point constant? Select all that apply. fractional part string part decimal point integer part exponent part character part

Fractional, Decimal, Integer, exponent

Given the three situations the void type is used in C, match the associated code with the situation. Function returns as void Function arguments as void Pointers to void

Function returns as void - void exit (int status) Function arguments as void - int rand(void) Pointers to void - void *malloc (size_t size)

Which data types are valid regarding integer literals for constants? Select all that apply. float hexadecimal decimal octal double

Hexadecimal, decimal, and octal.

What tools are required to set up an environment in order to write, compile, and run a program written in the C language? Select all that apply. C++ compiler Java compiler Text editor C compiler

Text Editor and C compiler

Constants cannot be altered during program execution. True False

True

In a C program, an individual statement must be ended with a semicolon. True False

True

Literals are equivalent to fixed values in regard to computer programming in the C language. True False

True

String literals are enclosed in double quotes. True False

True

Professional best practices state that when using constants in source code the syntax should be in which format? camel case None of these lower case upper case

Uppercase

Regarding identifiers for variables, functions, or any other user-defined item, which of the following are acceptable? Select all that apply. $variable VARIABLE _variable 2variable3 variable var23iable

Variable, _variable, variable, var23iable.

Regarding basic data types in C, match the data type to its definition. char int float double void

char- typically one byte and is an integer int- the most natural size of integer for the machine float- a single precision floating point value double- a double precision floating point value void- represents the absences of type

When defining a constant inside the main() function, which is the correct implementation? const int LENGTH = 10; #define LENGTH 10 const int LENGTH 10; #define int LENGTH 10;

const int LENGTH = 10

What is source code compiled into? It isn't, source code is ran directly byte language machine language bit language

machine language

What C operator is used to yield the storage size of the object or type in bytes? scanf() sizeof() printf() None of these

sizeof()

What type of file contains the source code? executable files source files text files object files

source files

When defining a constant as a preprocessor command, which of the following is the correct implementation? #define int LENGTH 10 const int LENGTH 10; const LENGTH 10 #define LENGTH 10

#define LENGTH 10 (means that length equals 10. When defining it in the preprocessor command the equal sign is not needed)

Match the parts of the program with its definition. ----------------------------------------------------------------- #include <stdio.h> int main() { /* my first program in C */ printf("Hello, World! \n"); return 0; }

#include <stdio.h> - preprocessor command int main() -main function where program execution begins /* my first program in C */ -comment printf("Hello, World! \n"); -Function available in c return 0; -terminates the main


Set pelajaran terkait

Pesticides and Herbicides: An Introduction Review

View Set

Psychology chapter 11,12, 13, 14

View Set