ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
#include <ctype.h>
#include <stdio.h>
int main(void) {
const char *s = "Hello World";
int n = 0;
for (const char *p = s; *p; p++)
if (isalpha((unsigned char)*p) && (*p & 0x20) == 0) n++;
printf("%d", n);
}- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
Bit 0x20 is clear only in uppercase letters, and the uppercase letters of Hello World are H and W. So the count is 2.
More C Programming questions
- What is printed? Assume int is 4 bytes and a pointer is 8 bytes. c #include <stdio.h> int main(void) { printf("%zu", sizeof(int[10]) /…
- What is printed? Assume unsigned long long is 64 bits. c #include <stdio.h> int main(void) { printf("%llu", (1ULL << 63) 2); }
- How many positions differ between the two strings? Compute with this program. c #include <stdio.h> int main(void) { const char p =…
- What is printed? Assume unsigned long long is 64 bits. c #include <stdio.h> int main(void) { unsigned long long p = 4000000000ULL…
- What is printed? c #include <stdio.h> int main(void) { int x = 5; int p = &x; p = p << 2 | 1; printf("%d", x); }
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint32t x = ~0u >> 3; int c = 0; for (; x; x &= x - 1) c++…