Question: Consider the following program that attempts to modify the contents of a struct via a function. What will be the output? #include using namespace std;

Consider the following program that attempts to modify the contents of a struct via a function. What will be the output?
#include
using namespace std;
struct Counter {
int value;
};
void increment(Counter c){
c.value++;
}
int main(){
Counter c;
c.value =0;
increment(c);
cout << c.value;
return 0;
}
Consider the following program that attempts to modify the contents of a struct via a function. What will be the output?
#include
using namespace std;
struct Counter {
int value;
};
void increment(Counter c){
c.value++;
}
int main(){
Counter c;
c.value =0;
increment(c);
cout << c.value;
return 0;
}
Compilation Error
0
-1
1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!