What will be the output of the following code?int main() { int a = 10; int *p = &a; *p = 20; printf("%d\n", a); return 0;}
Question
Solution 1
The output of the code will be 20.
Here's the step by step explanation:
- An integer variable
a
is declared and initialized with the value 10. - A pointer variable
p
is declared and it is assigned the address ofa
. So,p
is now pointing toa
. - The value at the address that
p
is poi Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv
Similar Questions
What will be the output of the following code?int main() { int a = 10; int *p = &a; *p = 20; printf("%d\n", a); return 0;}
What will be the output of the following C code?#include <stdio.h>void foo(int*);int main(){int i = 10;foo((&i)++);}void foo(int *p){printf("%d\n", *p);}
What will be the output of the following C code?#include <stdio.h>int *m(){int *p = 5;return p;}void main(){int *k = m();printf("%d", k);}5Junk value0Error
What will be the output of the following code snippet?123456#include <stdio.h> int main() { int a = 10, b = 4; printf("%d", a - b * 2); }
What will be output when you will execute following c++ code?int main(){int a=5,b=10;if(++a||++b)printf(“%d %d”,a,b);elseprintf(“Doraemon”);}1,24,95,96,10