C Language Capability Quiz (6)
1. (8 )What is the dierence of the following sentences? Say something about it
according to your own comprehension.
x=x+1;
++x;
x++;
Answer:
All the sentences mean add 1 to x, there was no di%erent between any two of
the sentences if execute single;
But x++ means add 1 after the calculation and why ++x means before;
There was di%erent between the following two sentences;
Eg: i = 2
m[i++] = y; means set the value of m[2] ,but m[++i] = y means set m[3].
2. (12)Answer the following questions.
On the assumption that m={1,2,3,4,5},i=2,y=10,what the content
of array m will be after executing "m[i++]+=y "?
Answer:
m = {1,2,13,4,5}
What is the meaning of expression "x+++y" in your opinion?
Answer:
Equal to (x++)+y
operator “++” has high priority than “+”
There’s a variable VAR, how to judge if it is signed or unsigned?
How to set the value in absolute address 0x4FDE to 0xABCD?
Answer:
*(int *)0x4FDE = 0xABCD;
3. (35)Write a function to calculate arithmetic expression in string format.
Assume that the parameter expression is valid and there're no parentheses.
double Calc(const char* aExp) // e.g. result of "1+2*3/4+10/2" is 7.5
#dene NULL 0;
double calculate(double num1, double num2, char operator )
{
switch(operator)
{
case '+':