Initial commit

This commit is contained in:
2022-04-28 04:34:45 +03:00
commit 4c0cdb2f71
30 changed files with 1218 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#include <iostream>
using namespace std;
/* Синтаксис:
возвращаемый_тип имя(тип_параметра параметр, ...) {
return значение;
}
*/
int timesTwo(int num) {
return num * 2;
}
void printNum(int num) {
cout << num << endl;
}
double squareroot(double n) {
/**
Метод Ньютона
*/
double root = n / 2;
for (int i = 0; i < 20; i++) {
cout << "Guess " << i << " root " << root << endl;
root = (.5) * (root + (n / root));
}
return root;
}
int main() {
int res = timesTwo(5); // Вызов функции, возвращающей значение
printNum(res); // Вызов функции, не возвращающей значение
cout << squareroot(9) << endl;
return 0;
}