Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

22. Write a program with a function 'fun' that takes an integer as its argument and changes the n-th bit (counting starting from the right,

image text in transcribed
22. Write a program with a function 'fun' that takes an integer as its argument and changes the n-th bit (counting starting from the right, and with 1) in its binary-number representation and replaces it with 1 if it is 0 and with 0 if it is 1 , and then returns the integer with replacements. For instance, fun (6,2) should return 4 because in 6=110(2) we replace 1 with 0 to obtain 100 . Similarly, fun (9,3)=13 since we replace 9= 1001(2) with 1101(2)

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_2

Step: 3

blur-text-image_3

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

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions