Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Rishikesh Kumar Rishi
Page 28 of 102
Golang Program to Find the Numbers which are Divisible by 7 and Multiple of 5 in a Given Range
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 range: 400Enter the upper range: 700420455490525560595630665700ExplanationUser must enter the upper range limit and the lower range limit.The for loop ranges from the lower limit to the upper limit.The value of i ranges from the lower limit to the upper limit.Whenever the remainder of i divided by 5 and 7 is ...
Read MoreGolang Program to Print the Largest Even and Largest Odd Number in a List
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 the list.Define a size variable.Initialize an array with size.Take user's input for array.Iterate in the array, and compare oddRes and oddEven numbers for the largest.Print the largest evenRes and oddRes.Example Live Demopackage main import "fmt" func main() { fmt.Printf("Enter the number of elements to be in the list:") var ...
Read MoreGolang Program to Print the Sum of all the Positive Numbers and Negative Numbers in a List
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 is odd or even and find the individual sum.Find the individual sum of negative numbers.Print all the sums.Enter the number of elements to be in the list: 4Element: -12Element: 34Element: 35Element: 89Sum of all positive even numbers: 34Sum of all positive odd numbers: 124Sum of all negative numbers: -12Enter the ...
Read MoreGolang Program to Print the Multiplication Table of a Given Number
StepsRead a number and store it in a variable.Print the multiplication table of the given number.Enter the number to print the table for: 77 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 637 x 10 = 70Enter the number to print the table for: 1717 x 1 = 717 x 2 = 3417 x 3 = 5117 x 4 = 6817 x 5 = 8517 x 6 = 10217 x 7 = 11917 x 8 = 13617 x 9 = 15317 x 10 = 170ExplanationUser must enter a number.Using a print statement, print the multiplication table of the given number.Example Live Demopackage main import "fmt" func main(){ var n int fmt.Print("Enter the number to print the multiplication table:") fmt.Scanf("%d", &n) for i:=1; i
Read MoreGolang Program to Take the Temperature in Celsius and Covert it to Farenheit
StepsTake the value of temperature in Celsius and store it in a variable.Convert it to Fahrenheit.Print the final result.Enter the temperature in Celsius: 32Temperature in Fahrenheit is: 89.6Enter the temperature in Celsius: 48Temperature in Fahrenheit is: 118.4ExplanationUser must first enter the value of temperature in Celsius.Using the formula: f=(c*1.8)+32, convert Celsius to Fahrenheit.Print the temperature in Fahrenheit.Example Live Demopackage main import "fmt" func main(){ var n int fmt.Print("Enter the temperature in Celsius:") fmt.Scanf("%d", &n) f:=(float32(n)*1.8)+32 fmt.Println("Temperature in Fahrenheit is:", f) }OutputEnter the temperature in Celsius:32 Temperature in Fahrenheit is: 89.6
Read MoreGolang Program to Convert Centimeters into Feet and Inches
StepsTake the height in centimeters and store it in a variable.Convert the height in centimeters into inches and feet.Print the length in inches and feet.Enter the height in centimeters: 50The length in inches: 19.7The length in feet: 1.64Enter the height in centimeters: 153The length in inches: 60.28The length in feet: 5.02ExplanationUser must enter the height in centimeters.The height in centimeters is multiplied by 0.394 and stored in another variable which now contains the height in inches.The height in centimeters is multiplied by 0.0328 and stored in another variable which now contains the height in feet.The converted height in inches and ...
Read MoreGolang Program to Check Whether a Given Year is a Leap Year
StepsTake the value of the year as input.Using an if-statement, check whether the year is a leap year or notPrint the final result.Enter the year to be checked: 2016The year is a leap year!Enter the year to be checked: 2005The year isn't a leap year!ExplanationUser must first enter the year to be checked.The if statement checks if the year is a multiple of 4 but isn't a multiple of 100 or if it is a multiple of 400 (not every year that is a multiple of 4 is a leap year).Then, the result is printed.Example Live Demopackage main import "fmt" func ...
Read MoreGolang Program to Print an Inverted Star Pattern
StepsTake a value from the user and store it in a variable, n.Use a for loop where the value of i ranges between the values of n-1 and 0 with a decrement of 1 with each iteration.Multiply the empty spaces with n-i and '*' with i and print both of them.Exit.ExplanationUser must first enter the value and store it in a variable, n.The for loop enables i to range between n-1 and 0 with a decrement of 1 with each iteration.For each iteration, " " is multiplied with n-i and '*' is multiplied with i to ensure correct spacing of ...
Read MoreGolang Program to Compute Simple Interest Given all the Required Values
StepsRead the values for principal amount, rate and time.Using the formula, compute the simple interest.Print the value for the computed interest.Enter the principal amount: 200Enter the time(years): 5Enter the rate: 5The simple interest is: 50Enter the principal amount: 70000Enter the time(years): 1Enter the rate: 4The simple interest is: 2800ExplanationUser must enter the values for the principal amount, rate and time.The formula: (amount*time*rate)/100 is used to compute the simple interest.The simple interest is later printed.Example Live Demopackage main import "fmt" func main() { var principal, time, rate int fmt.Print("Enter the principal amount: ") fmt.Scanf("%d", &principal) fmt.Print("Enter the time ...
Read MoreGolang Program to Print an Identity Matrix
The steps to print an identity matrix using Golang is as follows :Take a value from the user and store it in a variable, n.Use two for loops where the value of j ranges between the values of 0 and n-1 and the value of i also ranges between 0 and n-1.Print the value of 1 when i is equal to j, and 0 otherwise.Case 1:Enter a number: 4 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1Case 2:Enter a number: 5 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1Example Live Demopackage main import "fmt" func main(){ var n int fmt.Print("Enter a number: ") fmt.Scanf("%d", &n) for i:=0; i
Read More