Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language programing problem This daily will allow you to practice more with the bit wise operators and shifts. Consider the following modification of the

C language programing problem

This daily will allow you to practice more with the bit wise operators and shifts. Consider the following modification of the main program from daily 3:

#include  
int main(int argc, char* argv[]) { 
void set_flag(unsigned int* flag_holder, int flag_position); 
void unset_flag(unsigned int * flag_holder, int flag_position); 
int check_flag(unsigned int flag_holder, int flag_position); 
void display_32_flags(unsigned int flag_holder); 

}

unsigned int flag_holder = 0; 
display_32_flags(flag_holder); 
set_flag(&flag_holder, 3); 
set_flag(&flag_holder, 16); 
set_flag(&flag_holder, 31); 
unset_flag(&flag_holder, 31); 
unset_flag(&flag_holder, 3); 
set_flag(&flag_holder, 9); 
display_32_flags(flag_holder); 

return 0;

Write the code for the definition of unset_flag and display_32_flags so that the output of your program looks like the following:

image text in transcribed

You can think of the unset_flag function as taking an integer and making sure that the nth bit is a 0. You may find the ~ operator useful. It is used to flip the bits of a number making all the zero values 1s and all the 1s zeroes. As in the previous daily, the shifting operators and the bitwise and ( & ) and or ( | ) may also be useful. If you are doing multiplication or division then you are doing it wrong. The display_32_flags function should just print the information to the screen as was given in the previous assignment (just turn it into a function instead).

OCWindows system321cmd.exe 0000 0000 0000 0001 0000 0010 0000 0000 Press any key to continue.. _

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions