Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is C code. Please only use stdio.h and answer the questions in 5 and 6. Use

ID: 3700260 • Letter: T

Question

This is C code. Please only use stdio.h and answer the questions in 5 and 6.

Use printf to print your answers at the end(after 12).

Thank you.

1.Declare three integer variables a, b and c. Initialize them to 0, 100 and 225, respectively.

2. Print the value of each variable and its address.

3. Add the following declaration to your code:

int *pA = &a, *pB = &b, *p;

4. Print the value of each pointer and the value it points to (using the pointer)

5. Run your program multiple times.

a. Does any of the values *pA, *pB or *p change?

b. Does any of the values pA, pB or p change?

6. Change the value that p points to to 50 without declaring the valuable that p points to.
a. Can you print the value that p points to?

7. Declare an array z of 10 integers and initialize its elements to 0, 1, 2, …., 9

8. Print the address of each element in the array using the z[i] notation

9. Print the address of each element in the array using the z + i notation

10. Print the content of the array using z + i notation

11. Declare a string literal x and set it to value “hello”.

12. Change the second character of x to upper case. What happens?

Explanation / Answer

#include<stdio.h>

int main()
{
int a=0, b=100, c=225;

printf("Values : ");
printf("a=%d, b=%d, c=%d",a,b,c);

printf(" Addresses : ");
printf("a=%d, b=%d, c=%d",&a,&b,&c);

int *pA=&a, *pB=&b, *p;
printf(" Value of ponters : ");
printf(" *pA=%d, *pB=%d, *p=%d",pA,pB,p);

//Print the value of each pointer and the value it
//points to (using the pointer)
//We cant print *p as it is not pointing to any value
//till now.

printf(" Value pointing to : ");
printf(" *pA=%d, *pB=%d ", *pA,*pB);

//5.a:Values of *pA,*pB donot change
//5.b:Values of pA, pB, p donot change

// *p=50; We cant change the value of p to 50 directly
// printf(" *p=%d",*p); is wrong in this case

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote