adplus-dvertising
frame-decoration

Question

What is the output of the below code considering size of short int is 2, char is 1 and int is 4 bytes?
#include <stdio.h>
    int main()
    {
        short int i = 20;
        char c = 97;
        printf("%d, %d, %d\n", sizeof(i), sizeof(c), sizeof(c + i));
        return 0;
    }

a.

2, 1, 2

b.

2, 1, 1

c.

2, 1, 4

d.

2, 2, 8

Posted under C Programming

Answer: (c).2, 1, 4

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the below code considering size of short int is 2, char is 1 and int is 4 bytes? #include <stdio.h> int main() { short int i = 20;...

Similar Questions

Discover Related MCQs

Q. Which type conversion is NOT accepted?

Q. What will be the data type of the result of the following operation?

(float)a * (int)b / (long)c * (double)d

Q. Which of the following type-casting have chances for wrap around?

Q. Which of the following typecasting is accepted by C?

Q. When do you need to use type-conversions?

Q. For which of the following, “PI++;” code will fail?

Q. What is the type of the below assignment expression if x is of type float, y is of type int?
y = x + y;

Q. What is the value of the below assignment expression

(x = foo())!= 1 considering foo() returns 2

Q. Operation “a = a * b + a” can also be written as:

Q. for c = 2, value of c after c <<= 1;

Q. Which of the following is an invalid assignment operator?

Q. For initialization a = 2, c = 1 the value of a and c after this code will be

c = (c) ? a = 0 : 2;

Q. What will be the data type of the expression

(a < 50) ? var1 : var2;

provided a = int, var1 = double, var2 = float

Q. Which expression has to be present in the following?

exp1 ? exp2 : exp3;

Q. Value of c after the following expression (initialization a = 1, b = 2, c = 1):

c += (-c) ? a : b;

Q. Comment on the following expression?

c = (n) ? a : b; can be rewritten as

Q. In expression i = g() + f(), first function called depends on

Q. Which of the following operators has an associativity from Right to Left?

Q. Which operators of the following have same precedence?

P. "!=", Q. "+=", R. "&lt;&lt;="

Q. Comment on the following statement?

n = 1;
printf("%d, %dn", 3*n, n++);