C Questions and Answers – Signed Qualifier

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Signed Qualifier”.

Pre-requisite for C Signed Qualifier MCQ set: Video Tutorial on C Data Types – Bits & Bytes.

1. In a signed integer, the sign is represented by ___________
a) Least significant bit
b) Most significant bit
c) System dependent
d) The mean of the most significant bit and the least significant bit
View Answer

Answer: b
Explanation: In a signed integer, the most significant bit represents the sign whereas, in an unsigned integer, no bit is used to represent the sign.

2. Sign qualifiers can be applied to double.
a) True
b) False
View Answer

Answer: b
Explanation: Sign qualifiers cannot be applied to the data types: float and double
advertisement
advertisement

3. What will be the output of the following C code?

#include<stdio.h>
int main()
{
    signed char ch= ‘a’;
    printf(%u”,ch);
    return 0;
}

a) -65
b) 65
c) -97
d) 97
View Answer

Answer: d
Explanation: Only for completeness, sign qualifiers are available with char data type.
Note: Join free Sanfoundry classes at Telegram or Youtube

4. What will be the output of the following C code?

advertisement
#include<stdio.h>
main()
{
    signed char a[]= “BAT”;
    printf(%c”, a[1]);
    return 0;
}

a) -A
b) BAT
c) A
d) 65
View Answer

Answer: c
Explanation: Sign qualifiers are available for char data types only for completeness. Format specifier used: %c, which prints a character. a[1] will print ‘A’.
advertisement

5. What is the default state of an integer in c language?
a) Signed
b) Unsigned
c) System dependent
d) There is no default state
View Answer

Answer: a
Explanation: The default state of an integer in c language is signed. Hence we can store both positive and negative integer values in it.

6. Suppose we have: int a=100; (signed by default).
If we want to convert this to an unsigned long integer, we can do this by making the following small change:
a) int a=lu100;
b) int a= 100ul;
c) int a=uu100;
d) int a=100uu;
View Answer

Answer: b
Explanation: An integer literal can have a suffix that is a combination of U and L( uppercase or lowercase). The prefix specifies the base or the radix, ie: 0x for hexadecimal, 0 for octal and nothing for decimal.

7. What is the binary representation of the integer -14?
a) 11110
b) 01110
c) 01100
d) 11100
View Answer

Answer: a
Explanation: The left most bit (most significant bit) is used to represent the sign of the number: 0 for positive and 1 for negative. For example, a value of positive 14 is written as 01110(in binary). But a value of negative 14 is written as: 11110.

8. Which of the following header files must necessarily be included in your code, if you want to find the minimum value of unsigned short integer?
a) stdio.h
b) stdlib.h
c) limits.h
d) math.h
View Answer

Answer: c
Explanation: The header file limits.h is used to find the value of constants such as minimum and maximum. stdio.h: standard input and output, stdlib.h: standard library, math.h: mathematics functions library

9. What will be the error in the following C code?

main()
{
    long float a=-25.373e22;
    printf("%lf",a);
}

a) Negative number cannot be assigned to float data type
b) Long and float cannot be used together
c) Does not result in error
d) Logical error
View Answer

Answer: b
Explanation: It is not possible to use sign qualifier with float data type, however in the above code a negative value has been assigned to the variable without the use of sign qualifiers, which is possible. Hence, the answer is not “negative number cannot be assigned to float data type”. we know that size qualifier long is not applicable for float data type, hence the error.

10. What will be the output of the following C code?

main()
{
    unsigned a=10;
    long unsigned b=5l;
    printf(%lu%u”,a,b);
}

a) 105
b) 510
c) 10
d) error
View Answer

Answer: a
Explanation: The format specifiers which are for unsigned and long unsigned have been used in the code. Had we used the format specifiers in the reverse order, the output would still be the same.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.