# Interview Topics

The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 6 (denoted as 6!) is 1*2*3*4*5*6 = 720. Factorial is not defined for negative numbers and the factorial of zero is one,...

#### Factorial of a number in R Programming Language

The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 6 (denoted as 6!) is 1*2*3*4*5*6 = 720. Factorial is not defined for negative numbers and the factorial of zero is one,...

Input: nterms = as.integer(readline(prompt="How many terms? ")) # first two terms n1 = n2 = 1 count = 2 # check if the number of terms is valid if(nterms <= 0) { print("Plese enter a positive integer") } else { if(nterms == 1) { print("Fibonacci sequence:") print(n1) } else { print("Fibonacci sequence:") print(n1) print(n2)

#### Fibonacci Sequence in R Programming Language

Input: nterms = as.integer(readline(prompt="How many terms? ")) # first two terms n1 = n2 = 1 count = 2 # check if the number of terms is valid if(nterms <= 0) { print("Plese enter a positive integer") } else { if(nterms == 1) { print("Fibonacci sequence:") print(n1) } else { print("Fibonacci sequence:") print(n1) print(n2)

Input: num = as.integer(readline(prompt = "Enter a number: ")) # use for loop to iterate 10 times for(i in 1:5) { print(paste(num,'x', i, '=', num*i)) } Output: Enter your number: 8 "8 x 1 = 8" "8 x 2 = 16" ...

#### Multiplication Table in R Programming Language

Input: num = as.integer(readline(prompt = "Enter a number: ")) # use for loop to iterate 10 times for(i in 1:5) { print(paste(num,'x', i, '=', num*i)) } Output: Enter your number: 8 "8 x 1 = 8" "8 x 2 = 16" ...

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort in descending order we can pass decreasing=TURE. Note that sort is not in-place. This means that the original vector is not effected (sorted). Only a...

#### Sort a vector in R Programming Language

Sorting of vectors can be done using the sort() function. By default, it sorts in ascending order. To sort in descending order we can pass decreasing=TURE. Note that sort is not in-place. This means that the original vector is not effected (sorted). Only a...

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. Usage which.min(x) which.max(x) x <- c( 1, 4, 3, 9, 6, 7) which.max(x) Output: \$Rscript main.r 4 # position {Or} Position particular number(another way) x Output: ...

#### Find the position of minimum and maximum of value in R Programming Language

Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector. Usage which.min(x) which.max(x) x <- c( 1, 4, 3, 9, 6, 7) which.max(x) Output: \$Rscript main.r 4 # position {Or} Position particular number(another way) x Output: ...

Input: x <- c(2 ,3 ,4 ,6,1) min(x) y <- c(78,34,5,67,41,33) max(y) Output: \$Rscript main.r 1 78

#### Find the maximum and minimum number in R Programming Language

Input: x <- c(2 ,3 ,4 ,6,1) min(x) y <- c(78,34,5,67,41,33) max(y) Output: \$Rscript main.r 1 78

Input: x <- c(2 ,3 ,4 ,4) y <-c(3, 4 ,5 ,6) print (x+y) print(x-y) print(x*y) print(x/y) print(x%%y) print(x^y) or sum(x,y) prod(x,y) Output: \$Rscript main.r 5 7 9 10 -1 -1 -1 -2 6 12 20 24 0.6666667 0.7500000 0.8000000...

#### Write a R Program to Two vector Variables (Addition, Subtraction, Multiplication, Division, Mod, Coefficient)

Input: x <- c(2 ,3 ,4 ,4) y <-c(3, 4 ,5 ,6) print (x+y) print(x-y) print(x*y) print(x/y) print(x%%y) print(x^y) or sum(x,y) prod(x,y) Output: \$Rscript main.r 5 7 9 10 -1 -1 -1 -2 6 12 20 24 0.6666667 0.7500000 0.8000000...

Input: 2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div Output: 5 -1 6 0.6666667 14.66667 (Or) With input variable: x=6 y=2 x + y x-y x*y x/y Output: 8 4 12 3

#### R Programs to Add, Sub, Mul, and Div

Input: 2+3 //Add 2-3 //Sub 2*3 //Mul 2/3 //Div 2+2+3*4-4/3 // Add, Mul, Sub, Div Output: 5 -1 6 0.6666667 14.66667 (Or) With input variable: x=6 y=2 x + y x-y x*y x/y Output: 8 4 12 3