COP 3014 Final Exam With Correct
Solutions 2024
What .operator .returns .the .memory .address .of .the .variable? .- .correct .answer.address
.operator .(&)
char .= .1 .byte
int .= .4 .bytes
doubles .= .8 .bytes
int .x .= .25;
cout .<< .&x .<< .end; .//outputs .0x8f05
How .are .array .names .used .as .pointers? .- .correct .answer.array .names .are .pointers, .to .the
.first .element .in .the .array
What .are .local .and .global .variables? .- .correct .answer.Global .variables .are .defined
.outside .of .the .main
local .variables .are .defined .in .functions
What .statement .causes .a .function .to .end? .- .correct .answer.return .0;
What .does .a .pointer .store? .- .correct .answer.memory .addresses
What .is .the .difference .in .statements:
cout .<< .ptr .<< .endl;
cout .<< .*ptr .<< .endl; .- .correct .answer.ptr .prints .address
*ptr .prints .value .(dereferenced)
How .do .++ .and .-- .affect .pointers? .- .correct .answer.add .or .subtract .bytes
char .= .1 .byte
int .= .4 .bytes
doubles .= .8 .bytes
What .operations .can .be .used .on .pointers? .- .correct .answer.arithmetic .operations
, How .do .you .dynamically .allocate .memory? .- .correct .answer.use .the .new .function
How .do .you .declare .pointers .and .allocate .memory .to .them? .- .correct .answer.int .*iptr .=
.nullptr;
iptr .= .new .int; .//requests .computer .to .allocate .enough .memory .for .a .new .int .variable.
iptr .contains .the .address .of .the .newly .allocated .memory
use .*iptr .to .assign .values .to .dynamically .allocated .space
What .is .the .null .termination .character .for .character .strings? .- .correct .answer.\0
Pass .parameters .by .reference .vs .by .value? .- .correct .answer.reference .(ref) .changes
.value
value .is .a .copy
Type .of .data .returned .from .functions? .- .correct .answer.based .on .void, .int, .or .double
.function .declaration
How .many .characters .can .be .stored .in .the .array: .char .array[1000]? .- .correct .answer.999,
.because .of .null .character .\0
How .do .you .define .character .arrays? .- .correct .answer.char .greeting[6] .= .{'H', .'e', .'l', .'l', .'o',
.'\0'} .
=.
char .greeting[] .= ."Hello";
What .do .isupper .and .toupper .do? .- .correct .answer.isupper .checks .if .character .is
.uppercase .letter
toupper .converts .lowercase .letter .to .uppercase
How .to .declare .a .2D .array? .- .correct .answer.char .myarray[1000] .[1000];
Pass .as .parameter .in .prototype:
void .checkarray(int .a[ .][4]);
What .do .atoi .and .itoa .do? .- .correct .answer.atoi .converts .string .to .integer
itoa .converts .integer .to .string .(non-standard .function)
How .do .you .calculate .the .size .of .a .character .array? .- .correct .answer.Add .1 .to .array .size
.to .include .null .character .\0
How .do .you .declare .a .file .pointer? .- .correct .answer.>> .outputs .to .
Solutions 2024
What .operator .returns .the .memory .address .of .the .variable? .- .correct .answer.address
.operator .(&)
char .= .1 .byte
int .= .4 .bytes
doubles .= .8 .bytes
int .x .= .25;
cout .<< .&x .<< .end; .//outputs .0x8f05
How .are .array .names .used .as .pointers? .- .correct .answer.array .names .are .pointers, .to .the
.first .element .in .the .array
What .are .local .and .global .variables? .- .correct .answer.Global .variables .are .defined
.outside .of .the .main
local .variables .are .defined .in .functions
What .statement .causes .a .function .to .end? .- .correct .answer.return .0;
What .does .a .pointer .store? .- .correct .answer.memory .addresses
What .is .the .difference .in .statements:
cout .<< .ptr .<< .endl;
cout .<< .*ptr .<< .endl; .- .correct .answer.ptr .prints .address
*ptr .prints .value .(dereferenced)
How .do .++ .and .-- .affect .pointers? .- .correct .answer.add .or .subtract .bytes
char .= .1 .byte
int .= .4 .bytes
doubles .= .8 .bytes
What .operations .can .be .used .on .pointers? .- .correct .answer.arithmetic .operations
, How .do .you .dynamically .allocate .memory? .- .correct .answer.use .the .new .function
How .do .you .declare .pointers .and .allocate .memory .to .them? .- .correct .answer.int .*iptr .=
.nullptr;
iptr .= .new .int; .//requests .computer .to .allocate .enough .memory .for .a .new .int .variable.
iptr .contains .the .address .of .the .newly .allocated .memory
use .*iptr .to .assign .values .to .dynamically .allocated .space
What .is .the .null .termination .character .for .character .strings? .- .correct .answer.\0
Pass .parameters .by .reference .vs .by .value? .- .correct .answer.reference .(ref) .changes
.value
value .is .a .copy
Type .of .data .returned .from .functions? .- .correct .answer.based .on .void, .int, .or .double
.function .declaration
How .many .characters .can .be .stored .in .the .array: .char .array[1000]? .- .correct .answer.999,
.because .of .null .character .\0
How .do .you .define .character .arrays? .- .correct .answer.char .greeting[6] .= .{'H', .'e', .'l', .'l', .'o',
.'\0'} .
=.
char .greeting[] .= ."Hello";
What .do .isupper .and .toupper .do? .- .correct .answer.isupper .checks .if .character .is
.uppercase .letter
toupper .converts .lowercase .letter .to .uppercase
How .to .declare .a .2D .array? .- .correct .answer.char .myarray[1000] .[1000];
Pass .as .parameter .in .prototype:
void .checkarray(int .a[ .][4]);
What .do .atoi .and .itoa .do? .- .correct .answer.atoi .converts .string .to .integer
itoa .converts .integer .to .string .(non-standard .function)
How .do .you .calculate .the .size .of .a .character .array? .- .correct .answer.Add .1 .to .array .size
.to .include .null .character .\0
How .do .you .declare .a .file .pointer? .- .correct .answer.>> .outputs .to .