ProgrammingModerateTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", 'a' < 'b' && 'b' < 'c');
}- A. 0
- B. 2
- C. 3
- D. 1
Correct answer: D. 1
Both comparisons are true for the ASCII codes 97 < 98 < 99, so the logical AND gives 1.
More C Programming questions
- 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?
- char src[] = "hey"; char dst[8]; memcpy(dst, src, strlen(src)); printf("%d", (int)strlen(dst)); What is the problem with this code?