This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # program to give new string staring by 'if' , if string already have | |
| # 'if' at starting give unchanged string | |
| puts "Enter String :" | |
| str = gets.chomp | |
| if str[0,2] == 'if' | |
| puts str | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # take user inout string and find out how many vowels are there in string | |
| puts "Enter a String :" | |
| str = gets.chomp.downcase | |
| cnt = (str.count "a") + (str.count "e") + (str.count "i") + (str.count "o") + (str.count "u") | |
| puts cnt | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Create and array with 10 random values and find uniq elemets from it | |
| arr = Array.new(10) | |
| puts "Enter element for array:" | |
| for i in 0...10 | |
| arr[i] = gets.chomp | |
| end | |
| for i in 0...10 | |
| for j in 1...10-i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create array of 10 and sort | |
| arr = Array.new(10) | |
| puts "Enter element for array:" | |
| for i in 0...10 | |
| arr[i] = gets.chomp | |
| end | |
| for i in 0...10 | |
| for j in 1...10-i |
NewerOlder