TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Vowels and Consonants using PowerShell
Dorababu Meka
Jul 19
2016
Code
3
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
function VowelsandConsonants
{
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[
string
] $InputString
)
[
string
] $VowelString
[
string
] $ConsonantsString
$StringLength = @()
$StringLength = $InputString.Length
for
($i=0;$i -lt $StringLength;$i++)
{
if
($InputString[$i] -eq
"a"
-or $InputString[$i] -eq
"e"
-or $InputString[$i] -eq
"i"
-or $InputString[$i] -eq
"o"
-or $InputString[$i] -eq
"u"
)
{
$VowelString = $VowelString + $InputString[$i]
}
else
{
$ConsonantsString = $ConsonantsString + $InputString[$i]
}
}
Write-Host
"`n Vowles are !"
$VowelString -foregroundcolor
"green"
Write-Host
"`n Vowles are !"
$VowelString.Length -foregroundcolor
"green"
Write-Host
"`n Consonants are !"
$ConsonantsString -foregroundcolor
"red"
Write-Host
"`n Consonants are !"
$ConsonantsString.Length -foregroundcolor
"red"
}
VowelsandConsonants
Vowels and Consonants