C Programming · Question 25 · Medium

What will be the output of the following C program?

#include <stdio.h>

int main(void) {
    unsigned char c = 250;
    c += 10;
    printf("%d", c);
    return 0;
}
  1. -6
  2. 255
  3. 4
  4. 260
Answer and explanation

Answer: C. 4

Explanation: An unsigned char holds 0 to 255 (8 bits), and unsigned values wrap modulo 256. 250 + 10 = 260 is stored as 260 - 256 = 4.

Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?

Practise c programming

Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.

More c programming questions

More technical & programming practice

Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge