Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

Students also viewed these Databases questions