ProgrammingModerate
int a = 5, b = 2; printf("%d %d", a / b, a % b); What is printed?
- A. 2 2
- B. 2 1
- C. 2.5 1
- D. 3 1
Correct answer: B. 2 1
Integer division gives 2 and the remainder is 1, because 2 x 2 + 1 = 5.
More C Programming questions
- int main(void) { int a[] = {1, 2, 3}; printf("%zu", sizeof a / sizeof a[0]); } What is printed?
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t a[] = {200, 100, 50}; uint32t s = 0; uint8t t = 0; for…
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint32t m = 0x00A4u; for (int i = 0; i < 32; i++) if (m >> i &…
- 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 is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { int x = abs((const int )a), y = abs((const…
- This recursion counts the tilings of a 2 x n board with 2 x 1 dominoes. What is printed? c #include <stdio.h> int ways(int n) { if (n <=…