Addition of two numbers in a swift basic program

Addition of two number program in swift and it will print the number total value in output without having the third variable. without using third variable we can print the output in swift programming language like here.

print("addition of two numbers")

var a=1

var b=2

print(a+b)

 

Output:

addition of two numbers

3

What is var swift

To declare a variable in Swift, we utilise the var keyword. Variables are used in Swift to store and refer to values by their names. Before they can be utilised, variables must be declared. Static variables are variables that have the same value across all instances or objects of a class. When a variable is declared static, it is assigned to a class rather than an object.

Additional operator in swift programming

The addition operator instructs the compiler to add the operands ‘a’ and ‘b’ together. The types of built-in operators in C/C++ are categorised as follows. Operators for performing arithmetic/mathematical operations on operands are known as arithmetic operators.