Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Session2

import Foundation
import Glibc

/*
var a: Int = 5
var b: Int = 7 
var b1 = true

print("The sum is \(a+b) , the Subtract is \(a-b) , the Multiply is \(a*b) , the Dividing is \(a/b) , and the rest of the division is \(a%b)")
print("Are A and B is equal? \(a==b)")
print((a>b) && (a != b))
print(!b1)

//----------------------------------------------------------------------------------------------
//EX1 Solution :
var a: Int = 5
var b: Int = 7
var sum: Int = a + b
print(sum)
//----------------------------------------------------------------------------------------------

//EX2 Solution :

let secondsInAMinute = 60

// The number of seconds in a hour is 60 times the number 
// of seconds in a minute, which is 60.
let secondsInAHour = 60 * secondsInAMinute

// The number of seconds in a day is 24x the number of seconds in a hour. 
let secondsInADay = 24 * secondsInAHour

// The number of seconds in a year is 365x the number of seconds in a day. 
let secondsInAYear = 365 * secondsInADay

print(secondsInAYear)
//----------------------------------------------------------------------------------------------


//Ex3 Solution :
var widthOfScreen: Int = 30
var heightOfScreen: Int = 20

let numberOfPixels = widthOfScreen * heightOfScreen
print(numberOfPixels)

//----------------------------------------------------------------------------------------------

*/
let a: Int
let b: Int
let sumOfValues: Int = 10
let diffOfValues: Int = 4
b = (sumOfValues - diffOfValues) / 2
a = sumOfValues - b

print("a = \(a) and b = \(b)")

//OR

let value1: Int
let value2: Int
let sumOfValues2: Int = 10
let diffOfValues2: Int = 4
value1 = (sumOfValues + diffOfValues) / 2
value2 = sumOfValues - value1

print("Expected value of value1 = \(value1)  &  Expected value of value2 = \(value2)")













Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.