Question

33. What is output by the following program segment when function f3 iscalled twice? I void f30 3 static int x 0; x++; 6 cout x endl Your answer:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

#include <iostream>
using namespace std;
int f3()
{
static int x=0;
x++;
  cout<<" x is: "<< x <<"\n";
}

int main() {
static int n=0;
n=f3(); // Here first time we are calling f3() function
n=f3(); // Here we are calling f3() function twice
}

Output:

x is: 1 // Here value of x s 1 when calling f3() function for first time
x is: 2 // Here value of x is 2 when calling f3() function twice

Add a comment
Know the answer?
Add Answer to:
What is output by the following program segment when function f3 is called twice? void f3()...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT