Created
December 15, 2021 10:35
-
-
Save rozer007/9a668850bb897a95b91dfc9ba745b0dc to your computer and use it in GitHub Desktop.
Functions in julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1.What keyword is use to create a function in julia? | |
ans: The function keywors is use to create a function in julia. | |
Q2.What is the syntax for defining a function which accepts varible arguments? | |
ans: syntax: function name(parameter ...) | |
#body | |
end | |
Q3.What is a higher order function in julia? | |
ans: A function which takes function as a parameter or return a function. | |
Q4.In julia is it possible to return more than one value from a function. | |
ans: Yes , it is possible to return more than one values from a function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1.What will the output of this statement? | |
i=11 | |
function swap() | |
global i=90 | |
println(i) | |
end | |
swap() | |
println(i) | |
a) error | |
b) 0 | |
90 | |
c) 90 | |
90 | |
d) None of the above | |
ans: c) | |
Q2.What is the output of this statements: | |
function higher(val) | |
return function(x) return x+(val*x)+x end | |
end | |
m=higher(-3) | |
println(m(3)) | |
a) Error | |
b) -9 | |
c) -6 | |
d) -3 | |
ans: d) | |
Q3. What will be the output of this statements : | |
function ll(val) | |
val=val/2+8%2 | |
end | |
println(ll(10)) | |
a) 0 | |
b) 7 | |
c) 5 | |
d) 3 | |
ans: c) | |
Q4.What will be the output in this statements: | |
function hi() | |
return function(val) return log10(val) end | |
end | |
n=hi() | |
println(n(10)) | |
a) 1.2 | |
b) error | |
c) 1.0 | |
d) 10 | |
ans: c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment