# Interview Topics Here, You can learn Top Most asked C Programming Examples with Output for Freshers. C Programming Examples: 1. Write a C Program to Hello World 2. Write a C program to add two integers 3. Write a C program to addition, subtraction, multiplication, division...

#### Basic C Programming Examples With Output

Here, You can learn Top Most asked C Programming Examples with Output for Freshers. C Programming Examples: 1. Write a C Program to Hello World 2. Write a C program to add two integers 3. Write a C program to addition, subtraction, multiplication, division...

The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by the two given numbers. For example, the L.C.M. of 12 and 14 is 84. Program: lcm <- function(x, y) { # choose the greater number if(x...

#### Write a R Program to Find LCM

The least common multiple (L.C.M.) of two numbers is the smallest positive integer that is perfectly divisible by the two given numbers. For example, the L.C.M. of 12 and 14 is 84. Program: lcm <- function(x, y) { # choose the greater number if(x...

The highest common factor (H.C.F) or greatest common divisor (G.C.D) of two numbers is the largest positive integer that perfectly divides the two given numbers. For example, the H.C.F of 12 and 14 is 2. Program: hcf <- function(x, y) { # choose the...

#### Write a R Program to Find GCD

The highest common factor (H.C.F) or greatest common divisor (G.C.D) of two numbers is the largest positive integer that perfectly divides the two given numbers. For example, the H.C.F of 12 and 14 is 2. Program: hcf <- function(x, y) { # choose the...

Program: print_factors <- function(x) { print(paste("The factors of",x,"are:")) for(i in 1:x) { if((x %% i) == 0) { print(i) } } } Output: The factors of 24 are:" 1 2 3 4 6 8 12 24...

#### Find factors using R Programming Language

Program: print_factors <- function(x) { print(paste("The factors of",x,"are:")) for(i in 1:x) { if((x %% i) == 0) { print(i) } } } Output: The factors of 24 are:" 1 2 3 4 6 8 12 24...

Without Formula: num = as.integer(readline(prompt = "Enter a number: ")) if(num < 0) { print("Enter a positive number") } else { sum = # use while loop to iterate until zero while(num > 0) { sum = sum + num num = num - 1 } print(paste("The sum is", sum)) } Output: Enter a

#### Find sum of natural numbers without/with formula using R Programming Languge

Without Formula: num = as.integer(readline(prompt = "Enter a number: ")) if(num < 0) { print("Enter a positive number") } else { sum = # use while loop to iterate until zero while(num > 0) { sum = sum + num num = num - 1 } print(paste("The sum is", sum)) } Output: Enter a

An Armstrong number, also known as narcissistic number, is a number that is equal to the sum of the cubes of its own digits. For example, 370 is an Armstrong number since 370 = 3*3*3 + 7*7*7 + 0*0*0. Program: num = as.integer(readline(prompt="Enter a...

#### Check Armstrong number or Not in R Programming Language

An Armstrong number, also known as narcissistic number, is a number that is equal to the sum of the cubes of its own digits. For example, 370 is an Armstrong number since 370 = 3*3*3 + 7*7*7 + 0*0*0. Program: num = as.integer(readline(prompt="Enter a...

Input: year = as.integer(readline(prompt="Enter a year: ")) if((year %% 4) == 0) { if((year %% 100) == 0) { if((year %% 400) == 0) { print(paste(year,"is a leap year")) } else { print(paste(year,"is not a leap year")) } } else { print(paste(year,"is a leap...

#### Leap year or not in R Programming Language

Input: year = as.integer(readline(prompt="Enter a year: ")) if((year %% 4) == 0) { if((year %% 100) == 0) { if((year %% 400) == 0) { print(paste(year,"is a leap year")) } else { print(paste(year,"is not a leap year")) } } else { print(paste(year,"is a leap...

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,...