H
Haskell Prelude
Hello Friends -
Can anyone answer these C questions?
1. Given the following initial declarations and value assignments:
int ints[20] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
110, 120, 130, 140, 150, 160, 170, 180, 190, 200};
int *ip = ints + 3;
What value do the following expressions evaluate to? (Note that it is
possible for the values to be undefined.)
ints[4]
ip[4]
*ints + 4
*ip + 4
*(ints + 4)
*(ip + 4)
ints[-2]
ip[-2]
2. Implement a stack data stucture and the companion set of functions to
manipulate it. The payload of each element of the stack should be a double
value. The stack will need the following functions:
void push(stack s, double x); /* Which pushes the the value x on to
the top of the stack. */
double pop(stack s); /* Which pops the top value of the stack off an
returns it. */
double top(stack s); /* Which returns the top of the stack, but
doesn't remove it from the stack. */
int isEmpty(stack s); /* Which returns a true value if the stack is
empty, other wise false. */
void printstack(stack s); /* Which prints the stack. */
stack newStack(); /* Creates an empty stack. */
Thanks to all!
Can anyone answer these C questions?
1. Given the following initial declarations and value assignments:
int ints[20] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
110, 120, 130, 140, 150, 160, 170, 180, 190, 200};
int *ip = ints + 3;
What value do the following expressions evaluate to? (Note that it is
possible for the values to be undefined.)
ints[4]
ip[4]
*ints + 4
*ip + 4
*(ints + 4)
*(ip + 4)
ints[-2]
ip[-2]
2. Implement a stack data stucture and the companion set of functions to
manipulate it. The payload of each element of the stack should be a double
value. The stack will need the following functions:
void push(stack s, double x); /* Which pushes the the value x on to
the top of the stack. */
double pop(stack s); /* Which pops the top value of the stack off an
returns it. */
double top(stack s); /* Which returns the top of the stack, but
doesn't remove it from the stack. */
int isEmpty(stack s); /* Which returns a true value if the stack is
empty, other wise false. */
void printstack(stack s); /* Which prints the stack. */
stack newStack(); /* Creates an empty stack. */
Thanks to all!