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 variableaand assigns it the value7. -
int b = 17;This line declares an integer variableband assigns it the value17. -
int *c = &b;This line declares a pointercand assigns it the address ofb. This meanscis pointing tob. -
*c = 7;This line changes the value at the address pointed to bycto7. Sincecis pointing tob, this effectively changes the value ofbto7. -
cout << a << " “ << b << endl;This line prints the values ofaandbto the console. Sinceb's value was changed to7in 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.