function - What type of programming is this? -


i finished taking entry placement test computer science in college. passed, missed bunch of questions in specific category: variable assignment. want make sure understand before moving on.

it started out easy things, "set age equal age"

int age = 18, pretty simple

but then, had question had no clue how approach. went like...

"determine if character c is in alphabet , assign variable"

i function, issue is, gave me literally line write entire answer (so 50 characters max). here how answer box looked:

enter image description here

my first thought like

in_alphabet = function(c) {   var alphabet = ["a", "b" ... "z"]   if(alphabet.indexof(c) != -1)       return true; } 

but solution has 2 issues:

  1. how can set "c" value when whole function equal in_alphabet?
  2. i can't fit small answer box. 99% sure looking else. does know looking for? can't think of 1 line solution this

language doesn't matter (although solution in java/c++ preferred). appreciate guidance (doesn't have solution, don't know begin)

the question "determine if character c is in alphabet , assign variable" not ask create function (although in many languages best way this).

in r like:

inalphabet <- c %in% letters 

so can in 1 line in real-world languages. note letters built-in list of characters.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -