Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CNIT 105 Assignment10 Due: Wed. 4/11/18 20 Points Objectives: o Number Systems o Bitwise Operations o Masking Program: Write a C program to extract some

image text in transcribed
image text in transcribed
CNIT 105 Assignment10 Due: Wed. 4/11/18 20 Points Objectives: o Number Systems o Bitwise Operations o Masking Program: Write a C program to extract some information from a whole number for a secret mission as follows: The unit number: The lowest 3 bits in the number represent the unit number. For example if the number in binary is 01011001, the unit number will be 1. The safety signal: The 7th bit from the right is the safety signal. 1 indicates safety and 0 indicates danger. For example if the number in binary is 01011001, the signal is 1 and indicates safety. Number of tanks: The bits 4, 5, 6 from the right represents the number of missiles. For example if the number in binary is 01011001, digits 4, 5, 6 are 011 indicate 3 tanks. . Function Prototype: o Write function prototypes at the beginning of the program before maino. o Write the function definitions (the code) after main0. Required Function: Every function must be preceded with 4 its name, inputts), output type, and task lines of comments describing 1) get_ code0 function Input parameter: None Output: int ask: prompt the user to enter a whole number in range of -5000 and 5000, both inclusive (ivalues in this range fit in 2 bytes (16 bits) in memory. Validation: Use a loop to validate the range of the number 2) display_binary0 function Input parameter: int Output: void Task: Display the input number in 16 bit binary. Display a space between every 4 bits for clarity. main) o Declare variables of type int to store the input number (code), unit mumber signal, and tanks, o Invoke the function get code0 and store its output in variable code. o Display the code in hexadecimal (use %X in printf). o Invoke the function display binary) to display the code in binary o Declare a mask for unit number- the lowest 3 bits in the code. CNIT 105 Assignment10 Due: Wed. 4/11/18 20 Points Objectives: o Number Systems o Bitwise Operations o Masking Program: Write a C program to extract some information from a whole number for a secret mission as follows: The unit number: The lowest 3 bits in the number represent the unit number. For example if the number in binary is 01011001, the unit number will be 1. The safety signal: The 7th bit from the right is the safety signal. 1 indicates safety and 0 indicates danger. For example if the number in binary is 01011001, the signal is 1 and indicates safety. Number of tanks: The bits 4, 5, 6 from the right represents the number of missiles. For example if the number in binary is 01011001, digits 4, 5, 6 are 011 indicate 3 tanks. . Function Prototype: o Write function prototypes at the beginning of the program before maino. o Write the function definitions (the code) after main0. Required Function: Every function must be preceded with 4 its name, inputts), output type, and task lines of comments describing 1) get_ code0 function Input parameter: None Output: int ask: prompt the user to enter a whole number in range of -5000 and 5000, both inclusive (ivalues in this range fit in 2 bytes (16 bits) in memory. Validation: Use a loop to validate the range of the number 2) display_binary0 function Input parameter: int Output: void Task: Display the input number in 16 bit binary. Display a space between every 4 bits for clarity. main) o Declare variables of type int to store the input number (code), unit mumber signal, and tanks, o Invoke the function get code0 and store its output in variable code. o Display the code in hexadecimal (use %X in printf). o Invoke the function display binary) to display the code in binary o Declare a mask for unit number- the lowest 3 bits in the code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analytics And Quality Management Fundamental Tools

Authors: Joseph Nguyen

1st Edition

B0CNGG3Y2W, 979-8862833232

Students also viewed these Databases questions