Rp 1

 Prg01:length

a<-c(2,3,4,5)

b<-c(1,5,8,9,5)

if(length (a)==length (b))

{

Print("variable length of vector is same")

}

else

{

print("variable length of vector is not same")

}

Pgm02: illustrat with loop &stop condition to error 

for(i in 1:10)

 {

  print(paste("i =", i))

  

  if(i == 5)

 {

    stop("Iteration stopped (on condition) at i = 5")


  }

}

Pgm 03 :factorial 

fact<-function(n)

{

if(n<=1)

return (1)

else

return (n*(fact(n-1))

}

n<-3

print (paste("fact in number is :"fact(n)))


Program 4:min ,mid,mode

a<-c(8,10,4,6,23,5,9,8,5,4,8,7,8)

print (paste("mean=",mean(a))

print (paste("median=",median(a))

print (paste("mode=",names(sort(-table(a)))[1]))


Comments

Popular posts from this blog

C#