Scroll to Top

Sasken Interview Queastions & Answers

C Programming Questions and Answers – Type Conversions – 2

Here is a listing of C programming interview questions on “Type Conversions” along with answers, explanations and/or solutions:

1. function tolower(c) defined in library <ctype.h> works for ___________
a) Ascii character set
b) Unicode character set
c) Ascii and utf-8 but not EBCDIC character set
d) Any character set

Answer: d
Explanation: None.

2. What will be the output of the following C code considering the size of a 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

Answer: c
Explanation: None.

3. Which type of conversion is NOT accepted?
a) From char to int
b) From float to char pointer
c) From negative int to char
d) From double to char

Answer: b
Explanation: Conversion of a float to pointer type is not allowed.

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

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

a) int
b) long
c) float
d) double

Answer: d
Explanation: None.

5. Which of the following type-casting have chances for wrap around?
a) From int to float
b) From int to char
c) From char to short
d) From char to int

Answer: b
Explanation: None.

6. Which of the following typecasting is accepted by C?
a) Widening conversions
b) Narrowing conversions
c) Widening & Narrowing conversions
d) None of the mentioned

Answer: c
Explanation: None.

7. When do you need to use type-conversions?
a) The value to be stored is beyond the max limit
b) The value to be stored is in a form not supported by that data type
c) To reduce the memory in use, relevant to the value
d) All of the mentioned

Answer: d
Explanation: None.

« Prev – C Programming Questions and Answers – Type Conversions – 1
» Next – C Programming Questions and Answers – Increment and Decrement Operators – 1

 

Related posts

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
%d bloggers like this: