Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
0 of .
Results for:
P. 1

Ratings: (0)|Views: 392|Likes:

### Availability:

See More
See less

09/25/2010

pdf

text

original

L1.A1*Solution forL1.Q1
a = xxx * 10which is => a = ABC - XYZ * 10=> a = 20 - 10 * 10=> a = 20 - 100=> a = -80
L1.A2Solution forL1.Q2
Actual substitution is like this :calc(20+4, 10 -2) is calculated as follows(20+4 * 10-2) / (20+4 - 10-2)(20+40-2) / 1258 / 12 = 4.8since it is printed in %d the ans is 4
L1.A3Solution forL1.Q3
This problem will compile properly, but it will give runtime error. It will give divide-by-zero error. Look in tothe do loop portiondo { a /= cnt; } while (cnt --);when the 'cnt' value is 1, it is decremented in 'while( cnt --)' and on next reference of 'cnt' it becomes zero.a /= cnt; /* ie. a /= 0 */which leads to divide-by-zero error.
L1.A4Solution forL1.Q4
the result will be c = 40 and abc = 0;because the scope of the variable 'abc' inside if(c) {.. }is not valid out side that if (.) { .. }.
L1.A5Solution forL1.Q5
The answer is 7. The first condition ++k < 5 is checked and

it is false (Now k = 6). So, it checks the 3rd condition(or condition ++k <= 8) and (now k = 7) it is true. At thispoint k value is incremented by twice, hence the value of kbecomes 7.
L1.A6Solution forL1.Q6
The solution depends on the implementation of stack.(Depends on OS) In some machines the arguments are passedfrom left to right to the stack. In this case the resultwill beMain : 5 7 Fn : 7 7Other machines the arguments may be passed from right toleft to the stack. In that case the result will beMain : 6 6Fn : 8 7

L2.A1Solution forL2.Q1
The output will be : 0 10 11 20 21*s++ => *(s++)*++s=> *(++s)++*s=> ++(*s)
L2.A2Solution forL2.Q2
Some compiler (ansi) may give warning message, but it willcompile withouterrors.The output will be : 0 1 2 3 4 and -1
L2.A3Solution forL2.Q3
This is the problem about Unions. Unions are similar tostructures but it differs in some ways. Unions can beassigned only with one field at any time. In this case,unions x and y can be assigned with any of the one field aor b or c at one time. During initialisation of unions ittakes the value (whatever assigned ) only for the firstfield. So, The statement y = {100} intialises the union ywith field a = 100.In this example, all fields of union x are assigned withsome values. But at any time only one of the union fieldcan be assigned. So, for the union x the field c isassigned as 21.50.Thus, The output will beUnion 2 : 22 22 21.50Union Y : 100 22 22( 22 refers unpredictable results )
L2.A4Solution forL2.Q4
The pointer x points to the same location where y is stored.So, The changes in y reflects in x.The output will be :10 11 30 31 20 21 40 41
L2.A5Solution forL2.Q5
The output of this program is purely depends on the

## Activity (2)

### Showing

AllMost RecentReviewsAll NotesLikes