CPPForSchool.com: User Defined Function Set 1: Assignment 10

10. Write the output of the following program :


#include <iostream>
using namespace std;

static int i = 100;
void abc()
{
    static int i = 8;
    cout << "first = " << i++ << endl;
}

int main()
{
    static int i = 2;
    abc();
    cout << "second = " << i << endl;
    abc();
    
    return 0;
}

-----------------------------------------------------

first = 8
second = 2
first = 9



Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 7