Upload
charan
View
22
Download
8
Embed Size (px)
DESCRIPTION
Gradiance Online Accelerated Learning 2
Citation preview
8/25/2015 Gradiance Online Accelerated Learning
http://www.newgradiance.com/casu/servlet/COTC 1/3
Pavan Kumar
• Home Page
• Assignments Due
• Progress Report
• Handouts
• Tutorials
• Homeworks
• Lab Projects
• Log Out
Help
Gradiance Online Accelerated Learning
Homework Assignment Submitted Successfully.
You obtained a score of 9.0 points, out of a possible 9.0 points. You have answered all the questions correctly.
Congratulations, you have achieved the maximum possible score.
Submission number: 20347 Submission certificate: FI948776 Submission time: 2015-08-24 11:41:28 PST (GMT - 8:00)
Number of questions: 3 Positive points per question: 3.0 Negative points per question: 1.0 Your score: 9
Questions about strings, tokens, and the Lex language.
1. Here is a simple Lex program:
/* regular definitions */letter [A-Za-z]uletter [A-Z]x {uletter}+{letter}*
8/25/2015 Gradiance Online Accelerated Learning
http://www.newgradiance.com/casu/servlet/COTC 2/3
y {letter}{uletter}z {letter}*
%%
{x} {return(1);}{y} {return(2);}{z} {return(3);}
Suppose the input consists of a string of (upper- or lower-case) letters wfollowed by a nonletter (e.g., a blank). Determine for which values of w theLex program above will return 1, will return 2, and will return 3. Then, selectfrom the list below, a correct pair (w,i), where the program returns i when theinput is w.
a) (a, 1) b) (A, 3) c) (ab, 1) d) (aB, 2) Answer submitted: d)
You have answered the question correctly.
2. Divide the following C code into tokens:
float limitedSquare(x) float x { /* returns x-squared, but never more than 100 */ return(x<=-10.0||x>=10.0)?100:x*x; }
Which of the following is NOT one of the tokens?
a) float b) { c) 100 d) =
8/25/2015 Gradiance Online Accelerated Learning
http://www.newgradiance.com/casu/servlet/COTC 3/3
Copyright © 2007-2015 Gradiance Corporation.
Answer submitted: d) You have answered the question correctly.
3. What are all the (a) prefixes (b) proper prefixes of the string abacabad?Identify one of these from the list below.
a) acada is a prefix and a proper prefix. b) abacabad is a prefix, but not a proper prefix. c) abaca is a proper prefix, but not a prefix. d) abad is a prefix but not a proper prefix. Answer submitted: b)
You have answered the question correctly.