Please explain what should i do different?
myfunc<-function()
a=as.integer(readline(prompt="How many terms?"))
var1=0
var2=1
print(var1)
print(var2)
for(x in 1:a){
var3=var1+var2
print(var3)
var1=var2
var2=var3
}
myfunc()
Please explain what should i do different?
myfunc<-function()
a=as.integer(readline(prompt="How many terms?"))
var1=0
var2=1
print(var1)
print(var2)
for(x in 1:a){
var3=var1+var2
print(var3)
var1=var2
var2=var3
}
myfunc()
your function has only the line where you set a
if you want your function to have many code lines of content, then use curly brackets to contain the code
function(){
code lines
}
Why curly brackets are not required here. thanks in advance.
myfunc <- function()
{a=as.numeric(readline(prompt="Enter the value of x: "))
b=as.numeric(readline(prompt="Enter the value of y: "))
print(sum(a,b))}
myfunc()
They are there. Look again
Yeah, sorry for eating your time.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.