ProgrammingModerateTCS NQT · Wipro
What is printed?
What is printed?
#include <stdio.h>
int main(void) {
printf("%d", 10 / 3 * 3 + 10 % 3);
}- A. 9
- B. 10
- C. 2
- D. 1
Correct answer: B. 10
For positive ints (a / b) * b + a % b always equals a, so 3 * 3 + 1 = 10. 9 drops the % term, 2 groups the first part as 10 / (3 * 3), and 1 applies % 3 to the whole sum.
More C Programming questions
- What is printed? c #include <stdio.h> int main(void) { unsigned char c = 1; printf("%d", -c); }
- What is printed? c #include <stdio.h> #include <string.h> int main(void) { char s[] = "hello"; char p = strchr(s, 'l'); printf("%ld"…
- How many moves does this recursive Towers of Hanoi program make for 4 disks? Compute with the program. c #include <stdio.h> int moves = 0…
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t x = 0x96; uint8t r = (uint8t)((x << 3) | (x >> 5))…
- What is printed? Assume signed char is 8 bits, two's complement. c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void…
- What is printed? c #include <stdio.h> #include <stdlib.h> int cmp(const void a, const void b) { long long x = (const long long )a, y =…