Problem statementSend feedbackint a = 7;int b = 17;int *c = &b;*c = 7;cout << a << " “ << b << endl;
Question
Problem Statement
int a = 7;
int b = 17;
int *c = &b;
*c = 7;
cout << a << " " << b << endl;
Solution
The code you've written is in C++. Here's a step-by-step explanation of what it does:
-
int a = 7;
This line declares an integer variablea
and assigns it the value7
. -
int b = 17;
This line declares an integer variableb
and assigns it the value17
. -
int *c = &b;
This line declares a pointerc
and assigns it the address ofb
. This meansc
is pointing tob
. -
*c = 7;
This line changes the value at the address pointed to byc
to7
. Sincec
is pointing tob
, this effectively changes the value ofb
to7
. -
cout << a << " “ << b << endl;
This line prints the values ofa
andb
to the console. Sinceb
's value was changed to7
in the previous step, the output will be7 7
.
Similar Questions
Problem statementSend feedbackint a = 7;int b = 17;int *c = &b;*c = 7;cout << a << " “ << b << endl;
find the output of given code.#include <stdio.h>int main(){int a,b=110,c=20;printf("%d",a=b-=c*=5);return 0;}
Which of the following are invalid statements.*1 pointint Scanner = 45;int Class = 45;int main = 45;int If = 45;None of the above
Predict the output for the given code for func(8, 2) ?int func(int a, int b){ int c; c = a << b; return c;}Select one:a. 16b. 8c. 4d. 32
What will be the value of x after the following code snippet?int x = 5;x *= 2 + 3;Question 5Answera.10b.15c.25d.30
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.