Untitled

Run Settings
LanguageC++
Language Version
Run Command
// #include "pch.h" #include <iostream> using namespace std; // Functions prototypes int summa(int a, int b); double summa(double a, double b); float summa(float a, float b); long long factorial(long n); long long factorialR(long n); int main() { long n = 5; cout << endl << summa(1, 2); // function call cout << endl << summa(1.0f, 2.0f); // function call cout << endl << summa(1.0, 2.0); // function call cout << endl << endl << "Call of function with ITERATIVE calculation of factorial" << n << "! = " << factorial(n); // function call cout << endl << endl << "Call of function with RECURSIVE calculation of factorial" << n << "! = " << factorialR(n); // function call cout << endl << endl << endl; return 0; } // functions definitions long long factorialR(long n) { if (n > 1) return n * factorialR(n - 1); else return (long long)1; } long long factorial(long n) // function header { // begin of function body double result = 1; for (double i = 2; i <= n; i++) result = result * i; return (long long)result; // value return } // end of function body int summa(int a, int b) { cout << endl << "This fuction summa returns result of type: int\t"; return a + b; } double summa(double a, double b) { cout << endl << "This fuction summa returns result of type: double\t"; return a + b; } float summa(float a, float b) { cout << endl << "This fuction summa returns result of type: float\t"; return a + b; }
Editor Settings
Theme
Key bindings
Full width
Lines