94.7k views
5 votes
4. What is the output of the following code snippet? void prevnext(int a, int& prv, int nxt) { prv = a - 1; nxt = a + 1; } int main() { int a = 100; int b = 0;

User Spank
by
7.8k points

1 Answer

4 votes

Answer:

Previous = 99, Next = 101

Step-by-step explanation:

Given that a = 100

Previous says that it's formula is a - 1, where a = 100.

Therefore, previous code would show in its output as 100 - 1. 100 - 1 = 99.

Thus, the output of previous code will be 99

Like with previous, Next says that it's formula is a + 1, where a = 100.

Therefore, the next code would show in its output as 100 + 1. 100 + 1 = 101

Thus, the output of previous code will be 101

I hope that's explanatory enough. Thanks.

User Pierre Poliakoff
by
7.0k points