LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write a character string and find the number of vowels in it

Solved!
Go to solution

can someone solve this please

0 Kudos
Message 1 of 20
(2,158 Views)

Sounds like a homework assignment.  Regardless, we are here to help, not do you work for you.  What have you tried?  Where are you stuck?  You need to show some effort to get any real help.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 20
(2,154 Views)

i tried this but couldn't complete it

0 Kudos
Message 3 of 20
(2,127 Views)

You'll need to convert your VI to a previous version. Open your VI and select File - Save to Previous Version. I believe LV 2018 is 18.0. You'd be pretty safe converting it to that. That way, almost all forum members can take a look and offer help.

 

Eric1977_0-1692649619876.png

 

Message 4 of 20
(2,119 Views)

i changed the version

0 Kudos
Message 5 of 20
(2,109 Views)

I think you need to start over...

 

I see you are taking your text phrase and converting it into a byte array. If you right click on the right side of the String to Byte Array and select Crate - Indicator, you'll get a numeric array of unassigned integers which represent each character in your InputString.

 

Do a Google search on a ASCII table and focus on the Decimal column. What do you see?

Message 6 of 20
(2,092 Views)

Hi Arun,

 

Looks like a decent start, you are pretty close, but here are a few things to read that will help you:

 

1) ASCII Table: https://web.alfredstate.edu/faculty/weimandn/miscellaneous/ascii/ascii_index.html

2) Case Structures: https://www.youtube.com/watch?v=cgS3u0nupfs 

3) Counter In Labview: https://www.youtube.com/watch?v=_GghNq9UmUg

4) For Loop: https://www.youtube.com/watch?v=ziOnPNJgeVg

 

Remark, you want to count but you have nothing in your code that will "add/ increment" number count when a vowel is seen. Try to find out why you have "black" broken wires and find a way to fix them first.

 

Hint:

 

1) You would want to increment a count when a vowel is seen and make no change in the counter value when the string value is not a vowel.

2) 'A' = 65 (U8, 8 bit data) and 'a' = 97 (U8 data).

3) You may want to consider lower case 'a' and upper case 'A' values.

 

Message 7 of 20
(2,090 Views)

When you come across a big problem you can't solve, break it down into smaller problems you CAN solve. Here is one such way to do it (hint: most of these could be individual subVI's...)

 

1: Figure out how to identify if a single letter is a vowel

2: Figure out how to increment a counter with a "Yes" input, and not increment it with a "No" input

3: Figure out how to split a string into individual letters

4: Figure out how to loop through a list of individual letters

 

If you can do each of those simpler tasks, you can do the main one.

Message 8 of 20
(2,082 Views)
Solution
Accepted by topic author ARUN02

If you want to loop over individual elements, I wouldn't convert to a byte array:

wiebeCARYA_0-1692690330680.png

The string subset is very efficient, and won't copy the string. Instead it will return a substring, a decorated pointer to the original string. So there won't be data copies, and it will be fast.

 

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.

Message 9 of 20
(2,002 Views)

wiebe@CARYA wrote:

However, if you set Search and Replace String to match a regular expression:

wiebeCARYA_1-1692690500052.png

 

It count the replacements out of the box.

 

Note that I replace with a character (any character will do). If you don't wire the replacement, the string will be shrunk for every replacement, slowing things down.


I didn't know that not placing a replacement character can slow it down. I'll keep that in the memory bank for the next time I use it.

Message 10 of 20
(1,965 Views)