
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

159 Views
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 More

323 Views
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 More

242 Views
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

273 Views
Let's suppose the number is: 4Then, the Summation Patten would be:1 = 11 + 2 = 31 + 2 + 3 = 61 + 2 + 3 + 4 = 10StepsTake a value from the user and store it in a variable, n.Use two for loops where the value of t ranges between the values of 1 and n and the value of i ranges between 1 and t.Print the value of i and '+' operator.Find the sum of elements in the list.Print '=' followed by the total sum.Exit.Example Live Demopackage main import "fmt" func main(){ var n int fmt.Print("Enter number: ") fmt.Scanf("%d", &n) for t:=1; t

123 Views
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 1 and n.Print the value of i and '+' operator.Find the sum of elements in the list.Print '=' followed by the total sum.Exit.ExplanationUser must first enter the value and store it in a variable, n.The for loop enables i to range between 1 and n (as n+1 is not included).For each iteration, the value of i is printed.'+' operator is printed only if iExample Live Demopackage main import "fmt" func main(){ var n int ... Read More

374 Views
Let's assume the range is from 0 to 50. We have to print all the integers that aren't divisible by either 2 or 3.StepsUse a for loop ranging from 0 to 50.Then, use an if statement to check if the number isn't divisible by both 2 and 3.Print the numbers satisfying the condition.ExplanationThe for loop ranges from 0 to 50.The number is divided by 2 and 3.If the remainder ≠ 0, the number isn't divisible by either 2 and 3.The number satisfying the condition is printed.Example Live Demopackage main import "fmt" func main(){ for i:=1; i

4K+ Views
Suppose the number is: 123456Count of digits in the given number is: 6To count the number of digits in a number, we can take followingStepsTake the value of the integer and store in a variable.Using a while loop, get each digit of the number and increment the count each time a digit is obtained.Print the number of digits in the given integer.Example Live Demopackage main import "fmt" func main(){ var n int fmt.Print("Enter the number: ") fmt.Scanf("%d", &n) count := 0 for n >0 { n = n/10 count++ ... Read More

384 Views
Consider that the integer is: 75Divisor of that integer is: 3, 5, 15, ..., 75The smallest divisor is: 3StepsTake an integer from the user.Initialize a variable (res) with that number.Use a for loop where the value of i ranges from 2 to the integer.If the number is divisible by i, compare with res. If res > i, then update res with i.Exit from the loop and print res.Example Live Demopackage main import "fmt" func main(){ var n int fmt.Print("Enter the number: ") fmt.Scanf("%d", &n) res := n for i:=2; i

433 Views
To print odd number in a range, we can take two inputs, a and b, for lower and upper limits.Examplea = 2 and b = 9Numbers between a and b are: 2, 3, 4, 5, 6, 7, 8, 9Odd numbers are: 3, 5, 7, 9StepsDefine two numbers, a and b.Take user inputs for the numbers, a and b.Iterate the number between a and b.Find the modulo of 2, print the number if modulo of 2 of that number is not zero.Example Live Demopackage main import "fmt" func main(){ var a, b int fmt.Print("Enter lower limit number: ") fmt.Scanf("%d", ... Read More

552 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 the second number and scan the number.Print statement for the third number and scan the number.Initialize an array with numbers, a, b and c.Iterate the array with iterator i, j and k.Print (i, j, k)th index number of the array.Example Live Demopackage main import "fmt" func main(){ var a, b, ... Read More