(4 points) Identify the errors in the following statements.

int* p = &44;

- i think the star is the error because pointers are supposed to be like *p??

char c = 'w';
char p = &c;

- if its char wouldnt that also be in apostrophe?
So char c= 'w' and char p = '&c' or &'c'???


char c = 'w';
char* p = c;

- still with the star thing, does that not go directly before variable?, also the c not in apostrophes?




float x = 3.14159
float* p = &x;
int d = 44;
int* q = &d;
p = q;

-maybe im wrong but i really thought the star goes directly before. I think i am now. I know the star declares a pointer. I don't know the error in this one

first step: try compiling the code. What errors do you get?

Let's go through each statement and identify the errors:

1. int* p = &44;
The error in this statement is that you cannot assign the address of a literal value (in this case, 44) to a pointer. Pointers can only store addresses of variables. To fix this, you can define an integer variable and then assign its address to the pointer: int num = 44; int* p = #

2. char c = 'w';
char p = &c;
In this statement, there is an error in assigning the address of a character ('w') to a variable. To declare a pointer to a char, you should use the star (*) followed by the variable name: char c = 'w'; char* p = &c;

3. char c = 'w';
char* p = c;
Here, the error is attempting to assign a character ('w') directly to a pointer. To assign the address of a character to a pointer, the variable should be preceded by the ampersand (&): char c = 'w'; char* p = &c;

4. float x = 3.14159;
float* p = &x;
int d = 44;
int* q = &d;
p = q;
There is no error in this statement. It declares a float variable (x), assigns its address to a float pointer (p), declares an integer variable (d), assigns its address to an integer pointer (q), and then assigns the value of the pointer q to the pointer p.