In: Computer Science
write a C++ function called inc whose parameter is an integer reference type and that increases the parameter by one when it is called.
Source Code:
#include <iostream>
using namespace std;
void inc(int &x)
{
++x;
}
int main()
{
int num=10;
cout<<"Value of num
initially:"<<num<<endl;
inc(num);
cout<<"Value of num after 1st
call:"<<num<<endl;
inc(num);
cout<<"Value of num after 2nd
call:"<<num<<endl;
inc(num);
cout<<"Value of num after 3rd
call:"<<num<<endl;
}