subject

Program description: in this recitation assignment, will write a complete c program that accepts as input any two integers from the user and swaps both integers using bitwise operators only without a third variable. early on in your programming career, you were told that you need to use a third variable in order to swap two variables, but in this assignment, you will accomplish this task without the extra variable. we will use the bitwise xor operator to swap the integers as the bitwise xor operator evaluates each bit of the result to 1 if the corresponding bits of the operands are different and 0 otherwise. programming with c and unix optional reference textbook by adam hoover to be . your ta or fellow students although not required, you may find chapter 2 on bits, bytes, and data types in the system for this recitation assignment, complete the following tasks. you may receive guidance frorm 1. declare an integer pointer and then request memory using malloc () for an array of 2 integers. this means that you should request memory for a size of 2 times the size of an integer and assign it to int_ptr. use man 3 malloc for details on this system call 2. if the malloc ) system call failed to return memory, print out a meaningful error message and terminate the program 3. prompt the user to enter the first integer using printf and then read in the user's response using scanf, storing the integer in the first element of the integer array allocated in step 1. 4. prompt the user to enter the second integer using printf and then read in the user's response using scanf, storing the integer in the second element of the integer array allocated in step 1. 5. now, print out the original values of both the integers input by the user. 6. this next step is where the swapping is done: a. use the bitwise xor operator on both the array elements and assign the result to the first element. b. use the bitwise xor operator on both the array elements and assign the result to the second element. c. use the bitwise xor operator on both the array elements and assign the result to the first element. 7. now, print out the swapped values of both the integers input by the user. 8. finally, release the allocated memory using free () sample output (user input shown in bold): $ . /a. out enter first integer: 571 enter second integer: 18 original values: 1st 571 2nd18 swapped values: 1st- 18 2nd571 $ . /a. out enter first integer: -4 enter second integer: 288 original values: 1st -4 2nd288 swapped values: 1st 288 2nd - -4

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
Which demographic challenge is europe currently experiencing? a. an aging and decreasing population b. a baby boomc. an unequal distribution between males and females d. a large group of teenagers moving through the school system(i chose a but i'm unsure)
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Light travels at a speed of 186,000 miles a second. the distance light travels in a year is 5,865,690,000,000 miles/year 5,865,695,000,000 miles/year 58,656,950,000,000 miles/year 6,789,000,0000 miles/year
Answers: 1
question
Computers and Technology, 24.06.2019 02:10
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
question
Computers and Technology, 24.06.2019 11:40
100 pts. first person gets brainliest
Answers: 2
You know the right answer?
Program description: in this recitation assignment, will write a complete c program that accepts as...
Questions
question
Mathematics, 30.10.2020 22:30
question
Mathematics, 30.10.2020 22:30
question
Mathematics, 30.10.2020 22:30
question
Mathematics, 30.10.2020 22:30
Questions on the website: 13722363