Answers for "writing a function 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
2

How to make a function in C++

//first lets create a function
/*void is for starting something, anything after void will be the name of your
function which will be followed by () */
void yourFunction() {
//your code will be here, anything here will be the code in the yourFunction
  cout << "Functions"
}
//now we have to go to our main function, the only function the compiler reads
int main() {
  myFunction(); //you call the function, the code we put in it earlier will be executed
  return 0;
}
Posted by: Guest on November-01-2020
0

Function in C++

//Syntax
    void myFunction() {
  
  // code to be executed
}
Posted by: Guest on June-26-2021

Browse Popular Code Answers by Language