We wish define a string variable (really, it\'s an object, but think of it as be
ID: 3528193 • Letter: W
Question
We wish define a string variable (really, it's an object, but think of it as being like a variable) named last_name. (a) Write the preprocessor directive to include the requisite header file. (b) Write the statement to define last_name. (c) Write an assignment statement that assigns "Flintstone" to last_name. (d) A sequence of zero or more characters enclosed in double quotation marks, such as "Flintstone", is called a(n) (2 words). (e) Explain the difference (or is there) between "" and "?". (f) What is "" called? Note: ? represents the space character.
Here is a pic to the question more clear.
Explanation / Answer
String variables can be used wherever strings are expected, such as file names and keyword parameters. A string is defined to be a one dimensional array of ASCII characters. A string can be a literal quote string, such as, `this is a quote string', or an expression that results in a string, such as RCHAR(35.6). A literal quote string must begin with an opening quote, ` and end with a closing quote, '. A string variable is a single string, that is, a one dimensional array of characters. A string array variable is an array of strings. An element of a string variable is a single character. An element of a string array variable is a string. There is no maximum length for either a string variable or any element of a string array variable, nor a maximum number of elements of a string array variable. The elements of a string array variable need not be the same length. The CLEN function returns a scalar value equal to the length of a string. The TLEN command gives the number of string elements in a string array. A string variable, or an element of a string array variable, can be entered directly by means of an assignment. For example: TS=`This is a string' ! string variable TA[3]=`This is a string' ! array string variable: third element An entire string array variable can be created with the READTEXT command. Commands that expect strings, such as the TEXT command, which draws a string, or the PLOTTEXT command, which expects a file name as a parameter, will only accept a single string. Remember, though, that a string can be a literal quote string, a string variable, one element of a string array variable, and/or some combination of string functions and string operators. Table 4.7 shows all of the possible ways that a string variable can be considered to be equivalent to a single string, that is, can be used wherever a string is expected. Let a be a scalar and let x be a vector Suppose that TA is a string array variable and T is a string variable T = T[i] for i = 1, ..., CLEN(T) TA[a] = TA[a][i] for i = 1, ..., CLEN(TA[a]) T[x] = T[i] for i = x[1], x[2], ..., x[#] TA[a][x] = TA[a][i] for i = x[1], x[2], ..., x[#]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.