Bird
0
0

Given this task function: void Task(void *pvParameters) { int *p = (int *)pvParameters; printf("Number: %d\n", *p); vTaskDelete(NULL); } If called with a pointer to an int variable holding 10, what is printed?

medium📝 Predict Output Q5 of 15
FreeRTOS - Task Creation and Management
Given this task function: void Task(void *pvParameters) { int *p = (int *)pvParameters; printf("Number: %d\n", *p); vTaskDelete(NULL); } If called with a pointer to an int variable holding 10, what is printed?
ACompilation error
BNumber: 0
CNumber: 10
DGarbage value
Step-by-Step Solution
Solution:
  1. Step 1: Understand parameter usage

    The task receives a void pointer, cast to int pointer, then dereferenced to print the int value.
  2. Step 2: Given pointer points to int 10

    Dereferencing prints 10 correctly.
  3. Final Answer:

    Number: 10 -> Option C
  4. Quick Check:

    Proper pointer cast and dereference = correct value [OK]
Quick Trick: Cast void* to correct pointer type before dereferencing [OK]
Common Mistakes:
  • Dereferencing void* directly
  • Casting void* to int instead of int*
  • Passing value instead of pointer

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes