Nim Programming Tutorial | Episode 17 | Procedure Challenge

preview_player
Показать описание
In this video, I present you with a simple challenge, in which you make a procedure that does a simple calculation.
Рекомендации по теме
Комментарии
Автор

proc fahrenheitToCelsius(temp: float): float=
var respuesta: float
respuesta = (temp - 32) * 5 / 9
return respuesta

var temp = 0.0
var respuesta =fahrenheitToCelsius(temp)
echo temp, " F is ", respuesta, " C."

Coding in Spanish's actually a cool thing to do. :P

joseignacio
Автор

Not sure if this was implemented when you made the video, but nim has an implicit variable "result" that is returned from every proc which you can modify within the proc

drygordspellweaver
Автор

from strutils import parseInt


proc tempConversion(F: int): float =
var a = F - 32
var b = a * 5
var c = b / 9
return c


echo "Enter F: "


var d = parseInt(readLine(stdin))


var temp = tempConversion(d)


echo d, " F is ", temp, " C"

archie
visit shbcf.ru