What is the value of n after the following code is executed?int n = 98;int *p = &n;
Question
What is the value of n
after the following code is executed?
int n = 98;
int *p = &n;
Solution
The value of n
after the following code is executed would still be 98
.
Here's the step by step explanation:
-
int n = 98;
This line declares an integer variablen
and initializes it with the value98
. -
int *p = &n;
This line declares a pointer to an integerp
and assigns it the address ofn
. So,p
is now pointing ton
.
However, no operation is performed to change the value of n
after these lines. Therefore, the value of n
remains 98
.
Similar Questions
What will the result of num variable after execution of the following statements? int num = 58; num % = 11; the given code is in c
What is the output of the following code?int arr[] = {1, 2, 3, 4, 5};int *p = arr;p++;printf("%d\n", *p);
How many times is the comparison i >= n performed in the following program?int i = 300, n = 150;main(){ while (i >= n){ i = i-2; n = n+1; }}
write a program to print integer no, from 1 to n where n is the input from the user using do while loop in c language use getch
What will you see on the terminal?int main(void){ int *ptr; *ptr = 98; printf("%d\n", *ptr); return (0);}It doesn’t compileSegmentation Fault980
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.