C | Operators | Question 15
Predict the output of following program. Assume that the characters are represented using ASCII Values.
#include <stdio.h> #define VAL 32 int main() { char arr[] = "geeksquiz"; *(arr + 0) &= ~VAL; *(arr + 5) &= ~VAL; printf("%s", arr); return 0; } |
chevron_right
filter_none
(A) GeeksQuiz
(B) geeksQuiz
(C) Geeksquiz
(D) geeksquiz
(E) Garbage eeks Garbage uiz
Answer: (A)
Explanation: The crux of the question lies in the statement: *(arr + 5) &= ~VAL;
This statement subtracts 32 from the ascii value of a lower case character and thus converts it to upper case. This is another way to convert an alphabet to upper case by resetting its bit positioned at value 32 i.e. 5th bit from the LSB(assuming LSB bit at position 0).
Quiz of this Question
Recommended Posts:
- Operators in C | Set 2 (Relational and Logical Operators)
- C | Operators | Question 2
- C | Operators | Question 6
- C | Operators | Question 5
- C | Operators | Question 16
- C | Operators | Question 26
- C | Operators | Question 18
- C | Operators | Question 22
- C | Operators | Question 17
- C | Operators | Question 23
- C | Operators | Question 7
- C | Operators | Question 11
- C | Operators | Question 12
- C | Operators | Question 13
- C | Operators | Question 27


