Es gibt neue Codes für neue Funktionen. Es werden Werte geändert und gedreht und verbogen…
Quellcode für Funktion 4:
#include <iostream>
void changeValue(int &num) {
num = 50;
}
int main() {
int value = 10;
changeValue(value); // Funktion aufrufen und Wert auf 50 ändern
std::cout << value << "\n";
return 0;
}
Quellcode für Funktion 5:
#include <iostream>
void swapNums(int &x, int &y) {
int z = x;
x = y;
y = z;
}
int main() {
int firstNum = 10;
int secondNum = 20;
std::cout << "Before swap: " << "\n";
std::cout << firstNum << secondNum << "\n";
swapNums(firstNum, secondNum);
std::cout << "After swap: " << "\n";
std::cout << firstNum << secondNum << "\n";
return 0;
}
Quellcode für Funktion 6:
#include <iostream>
#include <string>
void modifyStr(std::string &str) {
str += " World!";
}
int main() {
std::string greeting = "Hello";
modifyStr(greeting);
std::cout << greeting << "\n";
return 0;
}