CPS 188: Midterm syntax EXAM Questions AND Correct Answers
--i or i--; - ✔✔shortened version of i=i-1;
! - ✔✔syntax for not
!= - ✔✔syntax for not equal to
}
int main() {
double num = -12.75;
int wholePart;
double fracPart;
char sign = split(num, &wholePart, &fracPart);
printf("Sign: %c\n", sign);
printf("Whole Part: %d\n", wholePart);
printf("Fractional Part: %.2f\n", fracPart);
return 0;
} - ✔✔returning mutliple results with pointers
&& - ✔✔syntax for and
#include <stdlib.h>, n = rand(), gives a random integer number between 0 and
RAND_MAX, a predefined constant macro. - ✔✔what is the syntax to include
, the standard library and random function (also describe what is does in more
detail)
++i or i++; - ✔✔shortened version of i=i+1;
<= - ✔✔syntax for less than or equal to
== - ✔✔syntax for equal to
>= - ✔✔syntax for greater than or equal to
|| - ✔✔syntax for or
A stack is a data structure in which only the top element can be accessed (think
a pile of dinner plates) - ✔✔what is a stack
a/=2; - ✔✔shortened version of a=a/2;
Adds a new element at the top of a stack. - ✔✔what does the push function do
all types of variables - ✔✔%d - integer
%lf - double
%c - char
%f - float
--i or i--; - ✔✔shortened version of i=i-1;
! - ✔✔syntax for not
!= - ✔✔syntax for not equal to
}
int main() {
double num = -12.75;
int wholePart;
double fracPart;
char sign = split(num, &wholePart, &fracPart);
printf("Sign: %c\n", sign);
printf("Whole Part: %d\n", wholePart);
printf("Fractional Part: %.2f\n", fracPart);
return 0;
} - ✔✔returning mutliple results with pointers
&& - ✔✔syntax for and
#include <stdlib.h>, n = rand(), gives a random integer number between 0 and
RAND_MAX, a predefined constant macro. - ✔✔what is the syntax to include
, the standard library and random function (also describe what is does in more
detail)
++i or i++; - ✔✔shortened version of i=i+1;
<= - ✔✔syntax for less than or equal to
== - ✔✔syntax for equal to
>= - ✔✔syntax for greater than or equal to
|| - ✔✔syntax for or
A stack is a data structure in which only the top element can be accessed (think
a pile of dinner plates) - ✔✔what is a stack
a/=2; - ✔✔shortened version of a=a/2;
Adds a new element at the top of a stack. - ✔✔what does the push function do
all types of variables - ✔✔%d - integer
%lf - double
%c - char
%f - float