Essays.club - Get Free Essays and Term Papers
Search

C Programming Exam

Autor:   •  August 9, 2017  •  4,250 Words (17 Pages)  •  616 Views

Page 1 of 17

...

Explanation:

Consider on the expression:

x = 10 +- 10u + 10u +- 10;

10: It is signed integer constant.

10u: It is unsigned integer constant.

X: It is signed integer variable.

In any binary operation of dissimilar data type for example: a + b

Lower data type operand always automatically type casted into the operand of higher data type before performing the operation and result will be higher data type.

As we know operators enjoy higher precedence than binary operators. So our expression is:

x = 10 + (-10u) + 10u + (-10);

= 10 + -10 + 10 + (-10);

= 0

Note: Signed is higher data type than unsigned int.

So, Corresponding signed value of unsigned 10u is +10 4.

Which of the following is not modifier of data type in c?

(A)

extern

[pic 16]

(B)

interrupt

[pic 17]

(C)

huge

[pic 18]

(D)

register

[pic 19]

(E)

All of these are modifiers of data type

[pic 20]

Explanation:

To know more about these go to following link:

5.

What will be output when you will execute following c code?

#include

void main(){

double num=5.2;

int var=5;

printf("%d\t",sizeof(!num));

printf("%d\t",sizeof(var=15/2));

printf("%d",var);

}

Choose all that apply:

(A)

4 2 7

[pic 21]

(B)

4 4 5

[pic 22]

(C)

2 2 5

[pic 23]

(D)

2 4 7

[pic 24]

(E)

8 2 7

[pic 25]

Explanation:

sizeof(Expr) operator always returns the an integer value which represents the size of the final value of the expression expr.

Consider on the following expression:

!num

=!5.2

=0

0 is int type integer constant and it size is 2 by in TURBO C 3.0 compiler and 4 in the TURBO C 4.5 and Linux GCC compilers.

Consider on the following expression:

var = 15/2

=> var = 7

=> 7

7 is int type integer constant.

Any expression which is evaluated inside the sizeof operator its scope always will be within the sizeof operator. So value of variable var will remain 5 in the printf statement.

6.

What will be output when you will execute following c code?

#include

void main(){

const int *p;

int a=10;

p=&a;

printf("%d",*p);

}

Choose all that apply:

(A)

0

[pic 26]

(B)

10

[pic 27]

(C)

Garbage value

[pic 28]

(D)

Any memory address

[pic 29]

(E)

Error: Cannot modify const object

[pic 30]

Explanation:

In the following declaration

const int *p;

p can keep address of constant integer.

7.

Consider on following declaration:

(i) short i=10;

(ii) static i=10;

(iii) unsigned i=10;

(iv) const i=10;

...

Download:   txt (38.8 Kb)   pdf (176 Kb)   docx (71.7 Kb)  
Continue for 16 more pages »
Only available on Essays.club