16.
MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.
16. (C Question) A bit of puzzle
Consider the following function:
#include<stdio.h>
void fun(int,int);
int main()
{
fun(-25512,-18206);
return 0;
}
void fun(int a,int b)
{
int c,d;
c=a+b;
d=((b^c)|(a^c))& ~(a^b))>>15;
printf("%d",d);
}
: Question 19
19. (C Question) Dynamic memory allocation
With respect to the differences between malloc and calloc, select the option(s) that are true.
Pick ONE OR MORE options
Show answer & explanation
Answer: A. A) ☑️ Calloc initializes the allocated memory with 0 (zero) while malloc just fills it with garbage
Standard evaluation according to engineering and computational science principles.
Step-by-step Derivation:
Step 1: Analyze problem specification.
Step 2: Derive theoretical solution.
Step 3: Select corresponding answer option.