Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needs to be written in C For this recitation assignment, complete the following tasks. You may receive guidance from your TA or fellow students. Declare

Needs to be written in Cimage text in transcribed

image text in transcribed

For this recitation assignment, complete the following tasks. You may receive guidance from your TA or fellow students. 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. 1. 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 Now, print out the original values of both the integers input by the user. 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 5. 6. 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 operatoron both the array elements and assign the result to the first element. Now, print out the swapped values of both the integers input by the user. Finally, release the allocated memory using free () 7. 8. SAMPLE OUTPUT (user input shown in bold): $ . /a.out Enter first integer: 571 Enter second integer: 18 Original values: 1st571 2nd18 Swapped values: 1st 18 2nd571 $ ./a.out Enter first integer: -4 Enter second integer: 288 Original values: 1st 2nd288 Swapped values: 1st = 288 2nd = -4

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions