xxxxxxxxxx
// Defining function to calculate sum of 2 numbers
function add() public view returns(uint){
uint num1 = 10;
uint num2 = 16;
uint sum = num1 + num2;
return sum;
}
xxxxxxxxxx
function addNumber(uint _number) public pure return (uint) {
uint value = 10;//local variable
value = value+number;
return value
}
//here public nmeans we can access outside of smart contract like from frontend
//pure means it don't access blockchain data
//instead of pure if function read from blockchain then it will be read.
//if we need to write data in blockchain we don't need to add any keyword like view and pure
xxxxxxxxxx
pragma solidity ^0.5.0;
contract Test {
function getResult() public view returns(uint){
uint a = 1; // local variable
uint b = 2;
uint result = a + b;
return result;
}
}
xxxxxxxxxx
// Defining function to calculate sum of 2 numbers
function add() public view returns(uint){
uint num1 = 10;
uint num2 = 16;
uint sum = num1 + num2;
return sum;
}
xxxxxxxxxx
function function-name(parameter-list) scope returns() {
//statements
}
xxxxxxxxxx
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
contract Function {
//Section 21 minutes function
// function name(parameter type parameterName) visibilityState(public,private,internal) stateMutability(pure,view) returns(types)
//stateMutability => pure(doesn't do anythings,when we do somethings internal)
// view => read somethings but not do anythings
function addNumber(uint _number) public pure returns (uint) {
uint value = 10;
value = value + _number;
return value;
}
//Section Compile 32 minutes.
//compile variables.sol
}