ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", -1 < (unsigned)0);
}- A. 1
- B. 0
- C. 2
- D. 3
Correct answer: B. 0
(unsigned)0 is 0 and -1 is converted to UINT_MAX, so -1 < 0 is false in this comparison. A signed comparison would print 1.
More C Programming questions
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { const int x = a, y = b; if (x[1] != y[1])…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {1, 2, 3, 4, 5}, p = a; printf("%d", (p + (p + 2))); }
- How many ways are there to place 3 non-attacking rooks on a 3 by 3 board? Compute with this program. c #include <stdio.h> int used[3]; int…
- In the sorted array {1, 3, 4, 4, 7}, what index is printed by this lower-bound search for key 4? c #include <stdio.h> int main(void) { int…
- How many of these statements are true for unsigned x = 5? Print the count from this program. c #include <stdio.h> int main(void) {…
- What is printed? c #include <stdio.h> int main(void) { int a[] = {5, 6, 7}, p = a + 1; printf("%d", p[-1] + p + p[1]); }