C++ Program:

- To Create a function to add 2 numbers

Example:

User Input: 2,3

Output: 5

#include <iostream>
using namespace std;

int sum(int n1,int n2){
  return n1+n2;
}

int main() {
  int n1, n2;
  cout<<"Enter two numbers: ";
  cin>>n1>>n2;
  cout<<"Sum : "<<sum(n1,n2);
  return 0;
}

Output:

  Enter two numbers : 7
  5
  Sum : 12
Program
basic
//function to add 2 numbers
int sum(int n1,int n2){
  return n1+n2;   //use add(+) operator
}

Since, function returns integer data type, so function starts with int

For devision (/), subtraction (-), multiplication (*), you can use their respective operators

Concept

Coming Soon !

Quick
Tutorial

Quote

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.