Rishikesh Kumar Rishi has Published 1156 Articles

Golang Program to Print all Numbers in a Range Divisible by a Given Number

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Aug-2021 06:03:22

467 Views

Let's assume the lower and upper limit for the range is 2 and 10, respectively, and the given number is 2.Iterate in the range of 2 to 10 and find modulo of 2 and print them.StepsDefine variables for upper and lower limit for the range.Print statement for upper and lower ... Read More

Golang Program to Read Three Digits and Print all Possible Combinations from the Digits

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Aug-2021 05:36:35

548 Views

Numbers are: a, b and c => 1, 2, 3Combination of (a, b, c) are: (1, 1, 1), (1, 2, 1), (1, 2, 2), (1, 2, 3), . . ., (3, 3, 3).StepsDefine the variables, a, b and c.Print statement for the first number and scan the number.Print statement for ... Read More

Golang Program to check if two numbers are Amicable Numbers

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 16:02:41

509 Views

StepsRead two integers and store them in separate variables.Find the sum of the proper divisors of both the numbers.Check if the sum of the proper divisors is equal to the opposite numbers.If they are equal, they are amicable numbers.Print the final result.Enter number 1: 220Enter number 2: 284Amicable!Enter number 1: ... Read More

Golang Program to Print the Numbers in a Range (1, upper) without Using any Loops

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:54:37

233 Views

StepsDefine a recursive function.Define a base case for that function that the number should be greater than zero.If the number is greater than 0, call the function again with the argument as the number minus 1.Print the number.Enter the upper limit: 512345Enter the upper limit: 1512..15Example Live Demopackage main import ( ... Read More

Golang Program to Find the Gravitational Force Acting Between Two Objects

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:53:38

430 Views

StepsRead both the masses and the distance between the masses and store them in separate variables.Initialize one of the variables to the value of gravitational constant, G.Then, the formula f=(G*m1*m2)/(r**2) is used to determine the force acting between the masses.Rounding off up to two decimal places, print the value of ... Read More

Golang Program to Find the Area of a Triangle Given All Three Sides

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:52:40

545 Views

StepsRead all the three sides of the triangle and store them in three separate variables.Using the Heron's formula, compute the area of the triangle.Print the area of the triangle.Enter first side: 15Enter second side: 9Enter third side: 7Area of the triangle is: 20.69Enter first side: 5Enter second side: 6Enter third ... Read More

Golang Program to Check if a Number is a Perfect Number

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:49:58

583 Views

StepsRead an integer and store it in a variable.Initialize a variable to count the sum of the proper divisors to 0.Use a for loop and an if statement to add the proper divisors of the integer to the sum variable.Check if the sum of the proper divisors of the number ... Read More

Golang Program to Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:48:27

530 Views

StepsTake in the upper and lower range and store them in separate variables.Use a for loop which ranges from the lower range to the upper range.Find the numbers which are divisible by both 5 and 7.Print those numbers.Case 1Enter the lower range: 1Enter the upper range: 1003570Case 2Enter the lower ... Read More

Golang Program to Print the Largest Even and Largest Odd Number in a List

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:47:15

536 Views

Enter the number of elements to be in the list: 5Element: 45Element: 20Element: 80Element: 93Element: 3Largest even number: 80Largest odd number 93Enter the number of elements to be in the list: 4Element: 23Element: 10Element: 34Element: 89Largest even number: 34Largest odd number 89StepsEnter the number of elements of to be in ... Read More

Golang Program to Print the Sum of all the Positive Numbers and Negative Numbers in a List

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 31-Jul-2021 15:45:21

343 Views

StepsRead a number of elements to be in a list.Take the elements from the user using a for loop and append to a list.Using a for loop, get the elements one by one from the list and check if it is positive or negative.If it is positive, check if it ... Read More

Advertisements