vec1 <- c(34,67,23,89,12,56,78,39,40,93,78,120,32,67)

#max(vec1)

#Printing the maximum number in vector without using max() function

sort(vec1,decreasing = TRUE)[1]

#Printing the 3rd index value without using vec1[3] directly

for (i in 1:length(vec1)){

if(i==3){

print(vec1*)*

}

}

#Append the fname1 with lname1 with a space

Fname <- c('fname1','fname2', 'fname3')

Lname <- c('lname1','lname2','lname3')

res<-c() #Each time we have to empty the vector, otherwise the value will get append

for (val in 1:length(Fname)){

for (val1 in 1:length(Lname)){

#Matching the index value, if matches it will add the value in the new vector

if(val==val1){

res<- append(res,c(Fname[val],Lname[val1]))

}

}

}

print(res)

#Inserting new value in between without using 'after'

vec <- c(34,77,89,34,7,00,33,22,77,99,18,44,79,45)

vec_1 <- vec[1:3]

vec_2 <- vec[4:length(vec)]

new_value <- 60

result<- c(vec_1,new_value,vec_2)

result

These codes works fine.