Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #pragma warning(disable : 4996) // needed in vs 1/ CSE 240 Spring 2022 Homework 2 Question 3 (25 points) // Note: You may notice

image text in transcribedimage text in transcribed

#include #pragma warning(disable : 4996) // needed in vs 1/ CSE 240 Spring 2022 Homework 2 Question 3 (25 points) // Note: You may notice some warnings when you compile in GCC or vs, that is okay. #define square(x) (x * x) #define mulMacro(a, b) (a + b + a + b * b* b) int mulfunc(int a, int b) { return (a + b + a * a + b } b* b* b); // Part 1: // We want to pass the value of 6 to square and expect the result of square to be 36, why is the result 25? Correct the error (5 points) void part1(int x) { int result; result = square(--); printf("square(6) = %d ", result); // Why did this error occur? Please provide the answer in your own words below. printf("Explanation: _ "); // (2.5 points) } // Part 2: // We want to pass decremented values of x and y to the macro and function to compare their outputs in VS and GCC. // Run this program in Visual Studio(VS) and then again in GCC. Fill the blanks below with the output values for mulFunc and mulMacro. // Then correct/edit this function so that mulFunc and mulMacro produce same correct output of 261. // (5 points) // void part2(int x, int y) { int x_copy = x, y_copy = y; printf("mulFunc(x, y) = %d mulMacro(x, y) = %d ", mulFunc(--X, --y), mulMacro(--X_copy, --y_copy)); // Replace the 4 blank spaces below with the actual output observed when running the code in VS and GCC. // The blanks should have the answers of unedited program. Keep the answers in blanks as they were, after editing the program. printf("In VS : the result of mulFun - and mulMacro = "); // (5 points) printf("In GCC: the result of mulfun = and mulMacro = "); // (5 points) // Explain in a short sentence why VS and GCC could possibly produce a different value for the same program and for the same input. printf("Explanation: _ "); // (2.5 points) } // Do not edit main() | int main() { int x = 7, y = 2; printf("Part 1: "); part1(x); printf("Part 2: "); part2(x, y); while (1); return 0; // needed to keep console open in VS }

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 Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Define what is meant by a Euroequity public share issue.

Answered: 1 week ago

Question

2. What type of team would you recommend?

Answered: 1 week ago

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago