What will be the output of the following C++ code?

#include <iostream>
   using namespace std;
   void addprint()
   {
       static int s = 1;
       s++;
       cout << s;
   }
   int main()
   {
       addprint();
       addprint();
       addprint();
       return 0;
   }

a) 234
b) 111
c) 123
d) 235

1 thought on “What will be the output of the following C++ code?”

Leave a Comment