Home » C++ Programming » Data Types » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    void Output()
    {
    static int p = 1;
    int k;
    for(k=p; k<=3; k++)
    {
    p++;
    cout << p;
    }
    }
    int main()
    {
    Output();
    Output();
    Output();
    return 0;
    }
    1. 0123
    2. 123
    3. 234
    4. 012345
    5. 01234
Correct Option: C

The variable that is declared as static has a file scope.



Your comments will be displayed only after manual approval.