pgm1.R number<-c(2,3,4,5,6,7,8) oddcount<-0 evencount<-0 if(length(numbers)>0) { for(num in numbers) { if(num%%2==0) { evencount<-evencount+1 }else{ oddcount<-oddcount+1 } } print(paste("total even numbers in vector is ",evencount)) print(paste("total odd numbers in vector is",oddcount)) }else{ print("your vector is emty") } pgm3.R { fact<-function(n) { if(n==0||n==1) return(1) else return(n*fact(n-1)) } n<-as.numeric(readline("enter n value")) paste("factorial of",n,"=",fact(n)) } pgm2.R { for(i in 1:10) { print(paste("i=",i)) if(i==5) stop("iteration stopped (on condition)at i==5") } }