Recap - Calculations
Part of the Fundamentals section of Coddy's GO journey. Lesson 21 of 109.
Challenge
EasyComplete the code to perform various arithmetic operations and display the results.
Try it yourself
package main
import "fmt"
func main() {
// Given variables
a := 10
b := 3
// TODO: Calculate and store the sum of a and b in a variable named 'sum'
// TODO: Calculate and store the difference (a - b) in a variable named 'difference'
// TODO: Calculate and store the product of a and b in a variable named 'product'
// TODO: Calculate and store the result of a divided by b in a variable named 'quotient'
// TODO: Calculate and store the remainder when a is divided by b in a variable named 'remainder'
// Print the results
fmt.Println("Sum:", sum)
fmt.Println("Difference:", difference)
fmt.Println("Product:", product)
fmt.Println("Quotient:", quotient)
fmt.Println("Remainder:", remainder)
}All lessons in Fundamentals
4Comparison & Logical Operators
Comparison Operators - Part 1Comparison Operators - Part 2Logical AND OperatorLogical OR OperatorLogical NOT OperatorOperator Precedence BasicsRecap - Making Comparisons7Control Flow: Loops
What The `for` Loop ExplainedFor Loop - BasicFor Loop - Condition OnlyThe `break` KeywordThe `continue` KeywordNested LoopsRecap - Repeating Actions2Variables and Basic Data Types
What is a variableType Inference with `:=`Integers (int)Floating-Point NumbersBooleansStringsZero ValuesConstantsNaming ConventionsRecap - Variables and Types5Basic Input/Output
Formatted OutputFormat VerbsPrinting TypesGetting Basic User InputRecap - Input and Output8Functions
Understanding FunctionsDeclaring a FunctionCalling FunctionsFunction ParametersReturning a Single ValueReturning Multiple ValuesNamed Return ValuesFunction Scope BasicsRecap - Creating Reusable Code3Basic Operators
Arithmetic OperatorsDivision OperatorThe Modulo OperatorAssignment OperatorAugmented Assignment OperatorsIncrement and DecrementRecap - Calculations6Control Flow: Conditionals
The `if` StatementThe `else` KeywordThe `else if` KeywordVariable Shadowing in `if`Initializing VariablesThe `switch` StatementSwitch with ExpressionsSwitch without ExpressionThe `fallthrough` KeywordRecap - Making DecisionsPractice on your own: Online Go compiler