Quadratic.swift

followed a formula rendering a code any news`?

// Quadratic Formula :chart_with_upwards_trend:

var a: Double = 6
var b: Double = -7
var c: Double =

var root1: Double
var root2: Double

// The positive root
root1 = (-b + (bb - 4ac).squareRoot()) / (2a)

// The negative root
root2 = (-b - (bb - 4ac).squareRoot()) / (2a)

// Outputting the roots
print(“Root 1 is (root1)”)
print(“Root 2 is (root2)”)

Hello @ikeliii, welcome to the forums! In Swift, to multiply variables together, you must use the * (multiplication) operator. For example:

var a: Double = 7
var b: Double = 8
var multiplication = a * b
//multiplication is now 56.0

Look where you’re multiplying variables. Are you using the correct operator all the time?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.