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;
}
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;
}
function in c++
#include <iostream>
using namespace std;
void function(){
cout << "I am a function!" << endl;
}
int main()
{
function();
return 0;
}
functions in C++
void Hello() {
std::cout << "Hello";
}
int main () {
Hello();
}
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;
}
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;
}
how to make a function in cpp
// function returning the max between two numbers
int max(int num1, int num2) {
// local variable declaration
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us