Q1. Print Name and Take User Input.
Ans: name <- readline("Enter your name: ")
cat("Hello,", name, "!\n")
Q2. Check Whether a Number is Even or Odd
Ans: num <- [Link](readline("Enter a number: "))
if (num %% 2 == 0) {
cat(num, "is Even\n")
} else {
cat(num, "is Odd\n")
Q3. Find the Largest of Three Numbers
Ans: a <- [Link](readline("Enter first number: "))
b <- [Link](readline("Enter second number: "))
c <- [Link](readline("Enter third number: "))
largest <- max(a, b, c)
cat("Largest number is:", largest, "\n")
Q4. Find Factorial of a Number Using Function.
Ans: fact <- function(n) {
if (n == 0) return(1)
return(n * fact(n - 1))
n <- [Link](readline("Enter a number: "))
cat("Factorial of", n, "is", fact(n), "\n")
Q5. Check Whether a Year is a Leap Year
Ans: year <- [Link](readline("Enter a year: "))
if ((year %% 400 == 0) || (year %% 4 == 0 && year %% 100 != 0)) {
cat(year, "is a Leap Year\n")
} else {
cat(year, "is Not a Leap Year\n")