ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
const char *s = "hello";
printf("%c%c", s[1], *(s + 4));
}- A. he
- B. ol
- C. eo
- D. ll
Correct answer: C. eo
s[1] is e and *(s + 4) is the last letter o, so the output is eo.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { int x = 1, y = 2; const int cp = &x; int const pc = &y; pc = 5; printf("%d %d", cp…
- What is printed? Assume double is 8 bytes. c #include <stdio.h> int main(void) { printf("%zu", sizeof(1 ? 'a' : 1.0)); }
- What is printed? c #include <stdio.h> #include <stdlib.h> #include <string.h> int cmp(const void a, const void b) { return strcmp((const…
- What index is printed when bsearch looks up "cat" in the sorted array {"ant", "bee", "cat", "dog"}? c #include <stdio.h> #include…
- How many ordered ways are there to write 10 as a sum of 1s, 2s and 3s? Compute with this program. c #include <stdio.h> int f(int n) { if…
- What is printed? c #include <stdio.h> int main(void) { unsigned n = 44; while (n & (n - 1)) n &= n - 1; printf("%u", n); }