fork download
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6. int UnitStateWord;
  7. unsigned char c,f;
  8. printf("Insert state code (0 - 31) >");
  9. scanf("%d",&c);
  10. UnitStateWord = (c & 0x1F) << 11;
  11. printf("\n? The result = %04x\n", UnitStateWord);
  12. printf("Insert if error exists (0/1) >");
  13. scanf("%d",&f);
  14. UnitStateWord |= (f & 1) << 9;
  15. printf("\n? The result = %04x\n", UnitStateWord);
  16. }
  17.  
  18.  
Success #stdin #stdout 0s 4496KB
stdin
1
1
stdout
Insert state code (0 - 31) >
? The result = 0800
Insert if error exists (0/1) >
? The result = 0a00