Knowee
Questions
Features
Study Tools

What will be the output of the following C code?#include <stdio.h>void main(){int k = 5;int *p = &k;int **m = &p; **m = 6; printf("%d\n", k);}A. 5B. Run time errorC. 6D. Junk

Question

What will be the output of the following C code?#include <stdio.h>void main(){int k = 5;int *p = &k;int **m = &p; **m = 6; printf("%d\n", k);}A. 5B. Run time errorC. 6D. Junk

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the given C code will be 6.

Here's the step by step explanation:

  1. An integer variable k is declared and initialized with the value 5.
  2. A pointer p is declared and it is initialized with the address of k.
  3. A pointer to a pointer m is declared and it is initialized with the address of p.
  4. The value at the address pointed to by m (which is the address pointed to by p, which is the address of k) is changed to 6. This effectively changes the value of k to 6.
  5. The value of k is printed, which is now 6.

So, the correct answer is C. 6.

This problem has been solved

Similar Questions

what will be the output of the c program?

What will be the output of the following code?

What will be the output of the following C++ code?

What will be the output of the following program?

What will be the output of the following C code?#include <stdio.h>int main() {    int i;    for (i = 0; i < 5; i++);    printf("%d\n", i);    return 0;}

1/4

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.