ProgrammingHardTCS NQT · Infosys pattern
What is printed?
What is printed?
int main(void) {
int x = 15;
int y = 4;
printf("%d %d %d", x / y, x % y, (x / y) * y + (x % y));
}- A. 3 4 15
- B. 3 3 15
- C. 3 3 14
- D. 4 3 15
Correct answer: B. 3 3 15
15/4 truncates to 3; 15%4 = 15-12=3. Verifying the division identity: (x/y)*y + (x%y) = 3*4+3 = 15 = x, as it always must for integer division/modulo.
More C Programming questions
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs…
- What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs…