Standard Utility Functions Flashcards

1
Q

absolute value of int n

A

abs(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

absolute value of long n

A

labs(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

quotient and remainder of ints n,d

A

div(n,d)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

pseudo-random integer [0,RAND_MAX]

A

rand()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

set random seed to n

A

srand(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

terminate program execution

A

exit(status)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

allocate storage

A

malloc(size), calloc(nobj,size)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

change size of storage

A

newptr = realloc(ptr,size);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

deallocate storage

A

free(ptr);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

search array for key

A

bsearch(key,array,n,size,cmpf)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

sort array ascending order

A

qsort(array,n,size,cmpf)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly