Question: Using C and the skeleton code provided below: Write a program (Q0.c) to do the following: In the main function, declare an integer, x. Then

Using C and the skeleton code provided below:

Write a program (Q0.c) to do the following:

In the main function, declare an integer, x. Then assign it to a random integer value in the interval [0, 10]. You should use the C math library random

number generator rand() function to generate a random number. Then Print the value and address (using the address of operator) of x . 1. In fooA(int * iptr), print the value of the integer pointed to by iptr, the address pointed to by iptr, and the address of iptr itself. Then change the value of of iptr as *iptr = 100; 2. In the main function, following the call to fooA(...), print the value of x. Answer the following question in a comment at the bottom of the file: Is the value of x different than the value that was printed at first? Why or why not?

Skeleton:

void fooA(int* iptr){ /*Print the value of iptr*/ /*Print the address pointed to by iptr*/

/*Print the address of iptr itself*/ /*Change the value of iptr itself*/ }

int main(){ /*declare an integer x and initialize it randomly to a value in [0,10] */ /*Print the address of x*/ /*Call fooA() with the address of x*/ /*Print the value of x*/

/*Answer the question */ return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!