Create an array of Indian city names, all in lower-case strings

create an array of Indian city names, all in lower-case strings.

Search cities Bangalore, Mumbai and Delhi from the array and do the following:

Display the reverse of the string, if the city is found.
Display message “City is not Bangalore, Mumbai or Delhi”, if city is not Bangalore, Mumbai or Delhi
For example, if the city found is bangalore, your program should output:

erolagnab
Please do provide the Solution of this task

1 Like

Hi @Gopikrishna_S

Try the below expression

new arrayvariable=Inputarray.Reverse().ToArray

Regards
Gokul

Fine

Let’s go step by step

arr_input is a variable of type array of strings

  1. Use a IF activity with condition like this

arr_input.Contains(“bengaluru”) OR arr_input.Contains(“mumbai”) OR arr_input.Contains(“delhi”)

If true it goes to then block where use a message box activity with string like this

String.Join(“”, arr_input.AsEnumerable.Reverse.ToArray())

If false it goes to else block where use a message box activity with string like this

“City is not Bangalore, Mumbai or Delhi”

Cheers @Gopikrishna_S

is it Correct bro according to your guidance

1 Like

Yeah @Gopikrishna_S


I am getting Output Like this

Fine

Let’s take it with another workaround

  1. Let’s take you have a array variable named arr_input with the array of input cities you have

  2. Now use a FOR EACH Activity and pass the above array variable as input and change the type argument as string in for each property panel

  3. Inside the loop use a IF condition like this

item.ToString.ToLower.Equals(“bengaluru”)

If true it goes to THEN block where mention the message box activity with input string like this

New String(item.ToString.ToCharArray.Reverse().ToArray())

If false it goes to ELSE Block where use a ASSIGN ACTIVITY LIKE THIS

bool_nobengaluru = True

Where bool_nobengaluru is a boolean type variable

Inside the same loop next to above if condition use another two if condition and have the same expression in then block and appropriate Boolean variables in else block named bool_nodelhi, bool_nomumbai

Now atlast inside the loop use a IF condition like this

bool_nobengaluru AND bool_nodelhi AND bool_nomumbai

If true it goes to THEN block where use a message box activity with string like this
“City is not Bengaluru or Mumbai or Delhi”

Cheers @Gopikrishna_S