×

Loading...
Ad by
Ad by

Who can write a good C programming?

本文发表在 rolia.net 枫下论坛Write a program that controls an Alarm System. Alarm System uses memory location CURRENT INPUT for several inputs (alarm sensors) that are being monitored: Ground Floor Window 1, Ground Floor Window 2, 2nd Floor Window, Front Door, Back Door, CO Alarm, Emergency Button, and Fire.
Default values of all inputs are stored in the memory location DEFAULT INPUT as ON, ON, ON, ON, ON, OFF, OFF, OFF. Default status represents the alarm sensors’ state that does not trigger an alarm. For example, the last bit represents the Ground Floor Window 1 and its normal state (state that does not trigger an alarm) is ON (represented with 1). When the window is opened, the bit changes to 0, and the alarm is triggered.
Write a C program that will ask the user to enter a Hex value representing the current state of the Alarm System inputs, and to determine which CURRENT INPUT bits are ON using a mask and an applicable Bitwise operation. The program will also print CURRENT INPUT in hexadecimal format, CURRENT INPUT in decimal format, and bit numbers of the CURRENT INPUT which are ON. An example of the output of your program could be as follows:

CURRENT INPUT is set to XX (Hex)
CURRENT INPUT is set to YY (Decimal)
Bits x x x are set.

Tips:
 Use the unsigned data type where applicable.
 Format specifier for Hexadecimal numbers is %x . Format specifier for unsigned integer numbers is %u.更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / Who can write a good C programming?
    本文发表在 rolia.net 枫下论坛Write a program that controls an Alarm System. Alarm System uses memory location CURRENT INPUT for several inputs (alarm sensors) that are being monitored: Ground Floor Window 1, Ground Floor Window 2, 2nd Floor Window, Front Door, Back Door, CO Alarm, Emergency Button, and Fire.
    Default values of all inputs are stored in the memory location DEFAULT INPUT as ON, ON, ON, ON, ON, OFF, OFF, OFF. Default status represents the alarm sensors’ state that does not trigger an alarm. For example, the last bit represents the Ground Floor Window 1 and its normal state (state that does not trigger an alarm) is ON (represented with 1). When the window is opened, the bit changes to 0, and the alarm is triggered.
    Write a C program that will ask the user to enter a Hex value representing the current state of the Alarm System inputs, and to determine which CURRENT INPUT bits are ON using a mask and an applicable Bitwise operation. The program will also print CURRENT INPUT in hexadecimal format, CURRENT INPUT in decimal format, and bit numbers of the CURRENT INPUT which are ON. An example of the output of your program could be as follows:

    CURRENT INPUT is set to XX (Hex)
    CURRENT INPUT is set to YY (Decimal)
    Bits x x x are set.

    Tips:
     Use the unsigned data type where applicable.
     Format specifier for Hexadecimal numbers is %x . Format specifier for unsigned integer numbers is %u.更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • what? 学科技术讨论?
      • Yes. I have difficult to write ...first understand topic.
    • 学校作业?
      定义一个
      union {
      unsigned char a;
      struct (unsigned char g1:1;
      unsigned char g2:1;
      ....
      }
      缺省值和新输入的值异或一下就知道哪一位变化了。