Answers for "how to call functions in c++"

C++
21

how to declare a function in c++

// function example
#include <iostream>
using namespace std;

int addition (int a, int b)
{
  int r;
  r=a+b;
  return r;
}
Posted by: Guest on March-04-2020
1

c++ functions inside functions

int main() {
    // This declares a lambda, which can be called just like a function
    auto print_message = [](std::string message) 
    { 
        std::cout << message << "n"; 
    };

    // Prints "Hello!" 10 times
    for(int i = 0; i < 10; i++) {
        print_message("Hello!"); 
    }
}
Posted by: Guest on September-04-2021
2

function declerations in C++

#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
using namespace std;

void function_one(double, double, double);

int main() {
  double r1 = 1.0;
  double r2 = 2.0;
  double x = 0.0;
  function_one(r1, r2, x);
  return 0;
}

void function_one(double rmin, double rmax, double x0) {
  cout << "Function got called" << endl;
}
Posted by: Guest on July-01-2020

Browse Popular Code Answers by Language