ProgrammingModerateTCS NQT · Infosys pattern
What is printed?
What is printed?
char *s = "Campus";
printf("%c%s", *(s + 1), s + 4);- A. aus
- B. apus
- C. Cus
- D. amus
Correct answer: A. aus
Indexing from 0: C a m p u s. *(s + 1) is the character 'a'; s + 4 is a pointer to "us", which %s prints until the '\0'. Together: aus.
More C Programming questions
- What is printed? c printf("%d", printf("hello"));
- On a 64-bit system (8-byte pointers, 4-byte int), what does f print? c void f(int a[10]) { printf("%zu", sizeof(a)); }
- How many times is fib called in total (including the first call) when evaluating fib(5)? c int fib(int n) { if (n <= 1) return n; return…
- What is printed? c int x = 181, c = 0; while (x) { x &= x - 1; c++; } printf("%d", c);
- What is printed? c printf("%d", 1 << 3 + 1);
- On a typical compiler where int is 4 bytes and 4-byte aligned, what is printed? c struct S { char c; int i; char d; }; struct T { int i…