ProgrammingHardProduct company OA
What is printed?
What is printed?
char s[] = "xya", *p = s;
char a = *p++;
char b = *++p;
char c = ++*p;
printf("%c%c%c %s", a, b, c, s);- A. xaa xyb
- B. xab xyb
- C. xyb xyb
- D. xab xya
Correct answer: B. xab xyb
*p++ reads 'x' and moves p to s[1]. *++p moves p to s[2] first and reads 'a'. ++*p increments the character at s[2], making it 'b', and yields 'b'. So the string itself is now "xyb".
More C Programming questions
- What is printed? c int hs(unsigned n) { return n ? (n & 0xF) + hs(n >> 4) : 0; } int main(void) { printf("%d", hs(0xBEEF)); }
- How many swaps does this bubble sort make? c int a[] = {3, 1, 4, 1, 5}, sw = 0; for (int i = 0; i < 5; i++) for (int j = 0; j < 4 - i…
- What is printed? c printf("%d %d", strncmp("abc", "abd", 2) == 0, strncmp("ab", "ab0x", 5) == 0);
- uint8t a = 200, b = 100; uint8t c = a + b; What is the value of c?
- With uint32t x = 5u - 7u; what is the value of x?
- uint32t x = 0x00F0A8u; what is x & (0u - x) in hexadecimal?