Created
December 15, 2021 07:29
-
-
Save rozer007/a2f41e9cadd1f6b040bf18b88545dd28 to your computer and use it in GitHub Desktop.
Loops 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 is the use of global keyword? | |
ans: Global keyword is use to access the global variable inside a block or a function. | |
Q2.What does the continue statement do? | |
ans: The continue statement, when the complier encountered the continue statement it will skip the execution of the rest code inside the loop and next iteration will start. | |
Q3.What does the break statememt do? | |
ans: The break statement is used to break out of the loop. | |
Q4. How can write a do while loop in julia? | |
ans: There is no do while loop 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. Which is the correct syntax for while loop? | |
a) while <condition> end | |
b) while <condition> | |
c) while <condition>: end | |
d) None of the above | |
ans: a) | |
Q2. What will the output of the statement ? | |
for i =10:-3:0 | |
print(i) | |
end | |
a)-3-6-9 | |
b)107321 | |
c)10741 | |
d)error | |
ans: c) | |
Q3.What will be the output of the statement ? | |
for i = 1:2, j = 2:2:5 | |
print((i, j)) | |
end | |
println() | |
a) (1, 2)(2, 2)(1, 4)(2, 4) | |
b) (1, 2)(1, 4)(2, 2)(2, 4) | |
c) (2, 1)(2, 2)(4, 1)(4, 2) | |
d) (2, 1)(4, 1)(2, 2)(4, 2) | |
ans: b) | |
Q4.What will be the output of this statement? | |
i=3 | |
while(i<6) | |
println("Hello pepcoder") | |
i+=1 | |
end | |
a) hello pepcoder | |
b) hello pepcoderhello pepcoderhello pepcoderhello pepcoder | |
c) hello pepcoderhello pepcoderhello pepcoder | |
d) Error | |
ans: d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment