What is the output of below C program?#include <stdio.h>int main(){int k = 5;int *p = &k;int **m = &p;**m = 6;printf("%d\n", k);} garbage65Compile time error
Question
What is the output of below C program?#include <stdio.h>int main(){int k = 5;int *p = &k;int **m = &p;**m = 6;printf("%d\n", k);} garbage65Compile time error
Solution
The output of the C program will be 6.
Here's the step by step explanation:
- An integer variable
kis declared and initialized with the value 5. - A pointer
pis declared and it is initialized with the address ofk. - A pointer to a pointer
mis declared and it is initialized with the address ofp. - The value at the address pointed to by
m(which is the address pointed to byp, which is the address ofk) is set to 6. This changes the value ofkto 6. - The value of
kis printed, which is now 6.
Similar Questions
What will be the output of the following program?
What would be the output of the following program?#include <stdio.h>int main( ){int j=1;while (j <= 255){printf ( "%c %d\n ", j, j );j++;}return 0;}ans.
What will be the output of the C program? ans.09119011 Previous Marked for Review Next
What will be the output of the following program?Note: This question helps in clearing AMCAT exam.12345678910#include <stdio.h>int main() { int c = 0, e = 0; for (e = 0;e < 5; e++) { c++; if (e == 3) break; } printf("%d",c);}
What will be the output of the following C program?#include<stdio.h>int main(){char c;c = 'A';printf("%c",c);return 0;}Select one:65Aac
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.