ProgrammingVery hardCompetitive coding (CP)
What is printed? Assume uint32t is 32 bits.
What is printed? Assume uint32_t is 32 bits.
#include <stdint.h>
#include <stdio.h>
int main(void) {
uint32_t a = 70000, b = 70000;
uint32_t p = a * b;
printf("%d", a != 0 && p / a != b);
}- A. 0
- B. 2
- C. 1
- D. 3
Correct answer: C. 1
The product wraps to 605032704, and dividing back gives 8643, which is not 70000. The division test therefore reports overflow.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { long long a = 1LL << 40; int b = (int)(a >> 20); printf("%d", b); }
- What is printed? c #include <stdio.h> int main(void) { int a[] = {4, 2, 5, 1}; for (int i = 0; i < 3; i++) printf("%d ", a[i] > a[i + 1] ?…
- How many pairs (i, j) with i < j have a[i] XOR a[j] equal to 5 for a = {1, 2, 3, 4}? Compute with this program. c #include <stdio.h> int…
- What is printed? c #include <stdio.h> struct N { int v; struct N nx; }; struct N rev(struct N h, struct N prev) { if (!h) return prev…
- What is printed? c #include <stdio.h> int main(void) { unsigned long long r = 1, b = 7; int e = 222; while (e) { if (e & 1) r = r b %…
- What is printed? c #include <stdio.h> int main(void) { unsigned h = 0; for (const char s = "abcdefgh"; s; s++) h = (h << 5) ^ (unsigned…