Answered step by step
Verified Expert Solution
Question
1 Approved Answer
STOP!!! Do not start working on this Lab until you have read the instruction below carefully and have had the two secret codes for this
STOP!!! Do not start working on this Lab until you have read the instruction below carefully and have had the two secret codes for this week ready. The total number of submissions you can make for this Lab is limited to 5, so make sure your code is correct and ready before submitting it. If any of the tests fails, check your code thoroughly and fix any issues, especially the secret codes you use, before your next submission attempt. For this lab, you should have had the two secret codes, which are two integer numbers, for this week (Week #8). These secret codes will be / were given out during this week's classes (Week #8 Tuesday and Thursday classes). Write a C program which does the following: 1. It defines a function named secret with the following prototype: int secret (const int x, int *result2); This function assigns result2 to the bit-wise XOR between x and the secret code #2, and returns as its output the bit-wise OR between x and the secret code #1. In particular, let the int variable secreti be the secret code #1 and the int variable secret2 be the secret code #2. Then result2 is x ^ secret2 and the return value is x secret1 2. The main program / function reads an integer number as x from input, calls the function secret() defined above with x being the read integer, then prints out the output value of secret() and the value of result2, each number on one line. Each number is printed in hexadecimal, using the format specifier %x of printf(). For example, if the secret codes were respectively, 123456 (secret1) and 654321 (secret2), then with the input 3582 the output is 1EFFE 9F60F because 123456 3582 = 126974 which is 1EFFE in hexadecimal, and 654321 ^ 3582 = 652815 which is 9F60F in hexademical. 289224.1756262.qx3zqy7 LAB ACTIVITY 8.14.1: LAB: Secret Codes 0/10 main.c Load default template. 1 #include 2 3 int secret(const int x, int *y) { 4 /* Type your code here. */ 5} 6 7 int main() { 8 9 /* Type your code here. */ return ; 11 12 13
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started