Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ program to add two numbers using function

#include <iostream>
using namespace std;

//function declaration
int addition(int a,int b);

int main()
{
	int num1;	//to store first number
	int num2;	//to store second number
	int add;	//to store addition 
	
	//read numbers
	cout<<"Enter first number: ";
	cin>>num1;
	cout<<"Enter second number: ";
	cin>>num2;
	
	//call function
	add=addition(num1,num2);
	
	//print addition
	cout<<"Addition is: "<<add<<endl;
	
	return 0;
}

//function definition
int addition(int a,int b)
{
	return (a+b);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ check open processes 
Cpp :: capacity() in c++ 
Cpp :: c++ remove whitespace from string and keep the same size 
Cpp :: c++ Modulo 10^9+7 (1000000007) 
Cpp :: c++ remove space from string 
Cpp :: size of 2d array in c++ 
Cpp :: copy substring to another string c++ 
Cpp :: char vector to string c++ 
Cpp :: accumulate c++ 
Cpp :: convert vector into array c++ 
Cpp :: c++ triangle 
Cpp :: convert string to stream c++ 
Cpp :: c++ loop through array 
Cpp :: iterate vector from end to begin 
Cpp :: c++ random 
Cpp :: cin.get vs cin.getline in c++ 
Cpp :: minimum spanning trees c++ 
Cpp :: how to add numbers in c++ 
Cpp :: c++ get time 
Cpp :: change abstract title name latex 
Cpp :: c++ find element in vector 
Cpp :: pbds in c++ 
Cpp :: convert all characters in string to uppercase c++ 
Cpp :: how to make a loop in c++ 
Cpp :: max element in array c++ stl 
Cpp :: for loop in c++ 
Cpp :: udo apt install dotnet-sdk-5 
Cpp :: set was not declared in this scope 
Cpp :: combine two vectors c++ 
Cpp :: joins in mysql use sequelize 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =