11.11: Exercises
- Page ID
- 54314
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
Below are some quiz questions and project suggestions based on this chapter.
Quiz Questions
Below are some quiz questions.
- What is the declaration for a character variable,
msg
, to contain the string “Hello World!”? - Given the following conditional expressions,
"D" > "c" "100" < "20" "Da" > "cA" "20" < "10" "d" > "C" "20" < "100" "ABBC" <= "ABCD"
state which will evaluate to true and which to false. - Given the following Fortran statements,
character(len=6) :: str1="abcdef", str2="ABCDEF" character(len=6) :: str3="123456", str4="78910" character(len=12) :: astr1, astr2, astr3, astr4 astr1 = str1(1:3) astr2 = str3(4:6) astr3 = str3 // str4 astr4 = str2(4:6) // str3(1:3) // str1(2:3)
provide the resulting strings (astr1
,astr2
,astr3
, andastr4
). - How can the integer value (based on the ASCII table) of a character be obtained?
- How can integer value be converted to a character (based on the ASCII table)?
Suggested Projects
Below are some suggested projects.
- Type in the case conversion example program, compile, and execute the program. Test the program on a series of different input values and verify that the output is correct for those input values.
- Update the case conversion example program to convert any upper-case characters to lower-case characters. Test the program on a series of different input values and verify that the output is correct for those input values.
- Write a program to read a string and count the vowels (“a”, “e”, “i”, “o”, and “u”). The program should provide a count for each vowel and a total count of vowels. The program should ensure that the vowels are counted for both upper and lower-case. Test the program on a series of different input values and verify that the output is correct for those input values.
- Write a program to read 5 strings (≤ 80 characters each) and display the strings in alphabetical order. Test the program with a variety of different input strings, including digits, upper-case, and lower-case characters. Test the program on a series of different input values and verify that the output is correct for those input values.