C++, CPP Tutorial – Count Characters in a String
Write a program that counts the letter ‘a’ in the word “Programming”. Solution: #include<iostream> using namespace std; int main(){ string strWord = "Programming"; int intCount = 0; for(int i =...
View ArticleF#, FSharp Tutorial – Count Characters in a String
Write a program that counts the letter ‘a’ in the word “Programming”. Solution: open System let main() = let strWord = "Programming" let mutable intCount = 0 for chLetter in strWord do if chLetter =...
View ArticleF#, F-Sharp Tutorial – Finding Text Matches in a String
Write a program that checks a string if it has a match inside another string. Solution: open System let main() = let strWord = "Programming" let strFind = "gram" if strWord.Contains(strFind) then...
View ArticleF#, F-Sharp Tutorial – Convert String to Integer
Write a program that converts “16” to integer. Solution: open System let main() = let strNum = "16" Console.WriteLine(Int32.Parse(strNum)) Console.ReadLine() |> ignore // Execute the main function...
View ArticleF#, FSharp Tutorial – Display Current Date and Time
Write a program that displays the current date and time (formatting is not required). Solution: open System let main() = let dtNow = DateTime.Now Console.WriteLine(dtNow.ToString())...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Highest Number From Three...
Define a function GetMax() that takes three numbers from the user as arguments and returns the largest of them. Output: Enter first number: 5 Enter second number: 7 Enter third number: 3 Highest...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Highest Number from Three...
Define a function GetMax() that takes three numbers as arguments and returns the largest of them. Output: 8 Solution: open System let main() = let intNum1 = 5 let intNum2 = 3 let intNum3 = 8 let...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Longest Word from Array
Write a function LongestWord() that takes a list of words and returns the length of the longest one. Output: Yellow Solution: open System let main() = let arrColors = [|"Blue"; "Yellow"; "Red"|] let...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Higher Number From User Input
Write a program that has a function that accepts a name and concatenates it to “Hello “. The function should return the combined strings. Output: Hello Mark Solution: open System let main() = let...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Higher Number From User Input
Define a function GetMax() that takes three numbers from the user then passes them as arguments to a function and returns the largest of them. Output: Enter first number: 3 Enter second number: 4...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Higher Number
Define a function GetMax() that takes two numbers as arguments and returns the largest of them. Output: 5 Solution: open System let main() = let intNum1 = 5 let intNum2 = 3 let GetMax (intValue1 :...
View ArticleC++, CPP Tutorial – Learn how to Program – Random Numbers
Write a program that generates a random number in the range of (1-10). Output: 4 Solution: #include<iostream> #include<stdlib.h> #include<time.h> using namespace std; int main(){...
View ArticleF#, FSharp Tutorial – Learn how to Program – Random Numbers
Write a program that generates a random number in the range of (1-10). Output: 4 Solution: open System let main() = let rand = new Random(); let randNum = rand.Next(1,11); Console.WriteLine("Random...
View ArticleF#, FSharp Tutorial – Learn how to Program – Find Higher Number
Write a Program that has outputs the higher number from two integers. Output: 4 Solution: open System let main() = let intNum1 = 3 let intNum2 = 4 Console.WriteLine(Math.Max(intNum1, intNum2))...
View ArticleF#, FSharp Tutorial – Learn how to Program – Largest of Two Numbers
Define a function GetMax() that takes two numbers as arguments and returns the largest of them. Output: 5 Solution: open System let main() = let intNum1 = 5 let intNum2 = 3 let GetMax (intValue1 : int)...
View ArticleF#, FSharp Tutorial – Learn how to Program – Length of String
Define a function that computes the length of a given list or string using an available method like length or by using a loop. Output: Length: 11 Length: 11 Solution: open System let main() = let...
View ArticleF#, FSharp Tutorial – Learn how to Program – Output Histogram
Define a procedure histogram() that takes a list of integers and prints a histogram to the screen. For example, histogram(4, 9, 7) should print the following: **** ********* ******* Output: This is a...
View ArticleF#, FSharp Tutorial – Learn how to Program – Temperature Conversion
Write a program that converts Celcius to Farenheit. Output: This program converts Celsius to Farenheit. Enter the temperature(Celsius): 100 ******************** 100.0 Celsius is equivalent to :...
View ArticleC++, CPP Tutorial – Learn how to Program – Weight Conversion
Write a program that converts kilogram to pounds, ounces, grams, and US tons. Output: This program converts kilogram to pounds, ounces, grams, and US tons. Enter the weight(kilogram/s): 5...
View ArticleF#, FSharp Tutorial – Learn how to Program – Weight Conversion
Write a program that converts kilogram to pounds, ounces, grams, and US tons. Output: This program converts kilogram to pounds, ounces, grams, and US tons. Enter the weight(kilogram/s): 5...
View Article