It works but the output is broken :)
This commit is contained in:
46
Semester 3/Assignments/functions/functions.cpp
Normal file
46
Semester 3/Assignments/functions/functions.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/cppFiles/main.cc to edit this template
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: functions.cpp
|
||||
* Author: caleb
|
||||
*
|
||||
* Created on March 1, 2024, 10:07 AM
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
#include "functions.h"
|
||||
|
||||
int global = 0;
|
||||
|
||||
void f1() {
|
||||
cout << "f1()" << endl;
|
||||
global++;
|
||||
f2();
|
||||
}
|
||||
|
||||
void f2() {
|
||||
cout << "f2()" << endl;
|
||||
global++;
|
||||
}
|
||||
|
||||
void passByReference(int& x) {
|
||||
global++;
|
||||
x = 100;
|
||||
}
|
||||
|
||||
void staticVarFunction() {
|
||||
static int staticInt = 10;
|
||||
staticInt++;
|
||||
cout << staticInt << endl;
|
||||
}
|
||||
|
||||
int& returnReference (int & x) {
|
||||
x++;
|
||||
return x;
|
||||
}
|
Reference in New Issue
Block a user