ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
unsigned short s = 1;
s <<= 15;
printf("%d", s);
}- A. 65536
- B. 16384
- C. 32768
- D. 1
Correct answer: C. 32768
Shifting 1 left by 15 gives 2^15 = 32768, which fits in unsigned short. A shift by 16 would not fit and would be wrong here.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { printf("%d", 'a' < 'b' && 'b' < 'c'); }
- char d[4]; char s[] = "abc"; strncpy(d, s, sizeof d - 1); d[sizeof d - 1] = '0'; printf("%s", d); What is printed?
- char w[16]; scanf("%15s", w); Why is the width 15 used?
- int c = 0; const char s = "Queue"; for (int i = 0; s[i]; i++) if (strchr("aeiou", tolower((unsigned char)s[i]))) c++; printf("%d", c)…
- printf("%.s", 2, "hello"); What is printed?
- int n = snprintf(buf, sizeof buf, "%s", text); if (n >= (int)sizeof buf) puts("truncated"); What does the test detect?