1 answer

1. Suppose the file mystery.txt contains the text below: The whole thing starts about twelve, fourteen...

Question:

1. Suppose the file mystery.txt contains the text below: The whole thing starts about twelve, fourteen or seventeen. #include
1. Suppose the file mystery.txt contains the text below: The whole thing starts about twelve, fourteen or seventeen. #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string word; int i 0; ifstream read("mystery.txt"); while(!read.eof()) { read>>word; if(i < word. length()) cout<<word[i]; i++; } cout<< endl; } seventeen teen

Answers

The output is : Thirteen

-------------------------------------------------------------------

Explanation:

Mystery.txt contains

The whole thing starts about twelve, fourteen or seventeen.

The above code prints ith character of the ith word, if i is less than word length

>>>> i = 0, word0 = The

i < wordlength, It will print 0th index character of  The which is : T

>>>> i = 1, word1 = whole

i < wordlength, It will print 1st index character of  whole which is : h

>>>> i = 2, word2 = thing

i < wordlength, It will print 2nd index character of  thing which is : i

>>>> i = 3, word3 = starts

i < wordlength, It will print 3rd index character of  starts  which is : r

>>>> i = 4, word4 = about

i < wordlength, It will print 4th index character of  about  which is : t

>>>> i = 5, word5 = twelve,

i < wordlength, It will print 5th index character of  twelve, which is : e

>>>> i = 6, word6 = fourteen

i < wordlength, It will print 6th index character of  fourteen which is : e

>>>> i = 7, word7 = or

i > wordlength, Since, i is greater than wordlength, skip printing

>>>> i = 8, word8 = seventeen.

i < wordlength, It will print 8th index character of  seventeen. which is : n

-------------------------------------------------------------------

Therefore, the output will be: Thirteen

-------------------------------------------------------------------

I hope this helps you,

Please rate this answer if it helped you,

Thanks for the opportunity

.

Similar Solved Questions

1 answer
Question 15 1 pts A $1,000 face value bond currently has a yield to maturity of...
Question 15 1 pts A $1,000 face value bond currently has a yield to maturity of 6.69%. The bond matures in three years and pays interest annually. The coupon rate of the bond is 7.00%. What is the current price of this bond? $823.43 $1,008.18 $1,000.00 $991.86...
1 answer
In a certain design, it is important that standard deviation of the current be less than...
In a certain design, it is important that standard deviation of the current be less than 25 mA. In a test of n=18 parts, the sample standard deviation is found to be 20 mA. Can we be 95% confident that the standard deviation will not exceed 24 mA?...
1 answer
In 2005, the lowest per capita GDP figures were seen in: a.   Transition countries (Central and...
In 2005, the lowest per capita GDP figures were seen in: a.   Transition countries (Central and Eastern European and Central Asian countries). b.   Latin America. c.   East Asia. d.   Arab States Please explain. Thanks!...
1 answer
What is the gradient of the line 5x-3y=7?
What is the gradient of the line 5x-3y=7?...
1 answer
As a bat flies toward a wall at a speed of 6.0 m/s, the bat emits...
As a bat flies toward a wall at a speed of 6.0 m/s, the bat emits an ultrasonic sound wave with frequency 30.0 kHz. What frequency does the bat hear in the reflected wave? Ship A is traveling 20 m/s due east. Ship B is traveling 15 m/s due west away from Ship A. Ship A sounds a horn with a frequency...
1 answer
Data were gathered from a simple random sample of cities. The variables are Violent Crime (crimes...
Data were gathered from a simple random sample of cities. The variables are Violent Crime (crimes per 100,000 population), Police Officer Wage (mean $/hr), and Graduation Rate (%). The accompanying table shows a multiple regression model for the variables. Complete parts (a) through (d). Data were ...
1 answer
Information bias in a study can come from which of the following sources d. Misclassification due...
information bias in a study can come from which of the following sources d. Misclassification due to poorly worded questions e. A and D f. B and C 11. Information bias in a study can come from which of the following sources? a. Inaccurate participant recall of an exposure b. A participant answer...
1 answer
Max bought a ticket to the championship baseball game for $190. Someone approaches him outside the...
Max bought a ticket to the championship baseball game for $190. Someone approaches him outside the stadium and offers him $405 for his ticket. If Max decides to go to the game, instead of selling his ticket, how much does it cost Max to go to the game? Multiple Choice $215 $190 $405 None of these....
1 answer
Equivalent Units of Production: Weighted average method The following information concerns production in the Finishing Department...
Equivalent Units of Production: Weighted average method The following information concerns production in the Finishing Department for May. The Finishing Department uses the Weighted average method. ACCOUNT Work in Process—Finishing Department ACCOUNT NO. Date Item Debit Credit Balance ...
1 answer
[13] 7. The magnetic field through the conducting square loop at the right changes according to...
[13] 7. The magnetic field through the conducting square loop at the right changes according to the relation B(t) - 2.5r-6.8t+5 T, where t is in seconds. Each side of the square is 321 cm long and the resistance is 56.8 u. Determine the current (magnitude and direction) in the loop at t- 5.6 seconds...
1 answer
A piston with a volume of 839.8 mL is filled with 0.162 moles of a gas...
A piston with a volume of 839.8 mL is filled with 0.162 moles of a gas at 352 K and 319.9 mm Hg. The piston is then compressed by 316.7 mL and cooled to 203.9 K. What is the pressure (in atm) of the piston under these final conditions?...
1 answer
Hello, two of these circled answers are incorrect. 1 6. The promoter sequences are the positions...
hello, two of these circled answers are incorrect. 1 6. The promoter sequences are the positions that: signal the initiation site of a gene (+1) B) bind the transcriptional factor that is associated with RNA polymerase e) attach the correct nucleotide triphosphate to the template DNA strand D) se...
1 answer
The pedigree below tracks the presence of albinism though a family's generation. Being albino is an...
The pedigree below tracks the presence of albinism though a family's generation. Being albino is an autosomal recessive trait. SO Albino model Connie Chiu What is the genotype of individual l-1? (use "a" to represent albinism/"A" to represent normal skin pigment)...
1 answer
A swimming pool constructed below ground level is ? = 2.5 m square and d =...
A swimming pool constructed below ground level is ? = 2.5 m square and d = 1.9 m deep (see figure below). A drain is at the bottom center of the pool. How far from the edge of the pool can a person whose eyes are h = 1.4 m above the ground stand and still see the drain?...
1 answer
Use C++ For this week’s lab you will write a program to read a data file...
Use C++ For this week’s lab you will write a program to read a data file containing numerical values, one per line. The program should compute average of the numbers and also find the smallest and the largest value in the file. You may assume that the data file will have EXACTLY 100 integer va...
1 answer
Hsu Company reported the following on its income statement: Income before income taxes $308,827 Income tax...
Hsu Company reported the following on its income statement: Income before income taxes $308,827 Income tax expense 92,648 Net income $216,179 Interest expense was $78,205. Hsu Company's times interest earned ratio (rounded to two decimal places) is a. 2.76 times Ob. 3.95 times c. 1.76 times d. 4...
1 answer
(1 point) Barbara makes a sequence of 22 semiannual deposits of the form X, 2X, X,...
(1 point) Barbara makes a sequence of 22 semiannual deposits of the form X, 2X, X, 2x, ... into an account paying a rate of 8.4 percent compounded annually. If the account balance 8 years after the last deposit is $10350, what is X? Assume the exact method of accumulation is in effect. Answer: $ 180...
1 answer
Do not round intermediate calculations. Give your final answer(s) to three significant figures. 1...
Do not round intermediate calculations. Give your final answer(s) to three significant figures. 144 MPa 96 MPa For the state of stress shown, determine two values of σ, for which the maximum shearing stress is 180 MPa Hint Sketch Mohr's circle for 3-dimensional stresses in terms of σ...