Concept explainers
What output will be sent to the stuff.dat when the following lines are executed (assuming the lines are embedded in a complete and correct
ofstream fout;
fout.open(“stuff.dat”) ;
fout << “*” << setw(5) << 123 << “*”
<< 123 << “*” <<endl;
fout.setf(ios::showpos);
fout << “*” << setw(5) << 123 << “*”
<< 123 <<“*”<<endl;
fout.unsetf(ios::showpos);
fout.setf(ios::left);
fout << “*” << setw(5) << 123 << “*”
<< setw(5) << 123 << “*” <<endl;
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (3rd Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Software Engineering (10th Edition)
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- in c++ with explanation!!!arrow_forwardHello I need some help with this. I keep getting this one wrong. The language program is Python.arrow_forwardThe template code defines a Time struct. Given main() that reads two Times and computes the difference between the two, complete the following two functions: main() provides ReadTime() to read input from a user and use the input to create a new Time by calling Create Time(). PrintTime() is provided to output Time in 24 hour format (hh:mm:ss). Ex: If the input is: the output is: 22 23 24 1 #include 2 #include 3 30 31 1. Time* CreateTime(int hours, int minutes, int seconds) o Allocate and return a new Time according to the parameters 2. Time* TimeDifference (Time* end, Time* start) o Allocate a new time to store the computed time difference 02 55 10 04 15 50 4 typedef struct Time_struct { 5 int hours; int minutes; int seconds; Time; 25 26 } 27 32 33 34 • Compute the amount of time elapsed from start to end. Assume start is always before end. o Adjust for negative minutes and seconds. o Return the pointer to Time that contains the difference 6 7 8 9 10 // ALLocate and return a Time as…arrow_forward
- Computer Science In a file named Exercise2.c write the function double sum(double (*f)(double), int start, int end); The call sum(g,i,j) should return g(i)+…+g(j). Add a main function to illustrate the use of your implementation of sum applied to sqrt from 1 to 10.arrow_forwardUsing C++ Write a void function GetYear that prompts for and inputs the year the operator was born (type int) from standard input. The function returns the user’s birth year through the parameter list (use pass by reference) unless the user enters an invalid year, in which case a BadYear exception is thrown. To test for a bad year, think about the range of acceptable years. It must be 4 digits (i.e. 1982) and it cannot be greater than the current year (the user obviously cannot be born in a calander year that has yet to happen!arrow_forwardAdd a function to get the CPI values from the user and validate that they are greater than 0. 1. Declare and implement a void function called getCPIValues that takes two float reference parameters for the old_cpi and new_cpi. 2. Move the code that reads in the old_cpi and new_cpi into this function. 3. Add a do-while loop that validates the input, making sure that the old_cpi and new_cpi are valid values. + if there is an input error, print "Error: CPI values must be greater than 0." and try to get data again. 4. Replace the code that was moved with a call to this new function. - Add an array to accumulate the computed inflation rates 1. Declare a constant called MAX_RATES and set it to 20. 2. Declare an array of double values having size MAX_RATES that will be used to accumulate the computed inflation rates. 3. Add code to main that inserts the computed inflation rate into the next position in the array. 4. Be careful to make sure the program does not overflow the array. - Add a…arrow_forward
- re Write a program which ends when a user types a user- defined letter. 1. Get an english letter as a sentinal value(a condition of termination). 2. The user will be asked to type an english letter until a user types above sentinel value. Hint: Use char type variables for english letters. e Sample output1: Pick an english letter to terminate: t Type an english letter: y Type an english letter: w Type an english letter: p Type an english letter: h Type an english letter: t Вye. Sample output2: e Pick an english letter to terminate: g Type an english letter: h Type an english letter: g Вye.arrow_forwardWrite a C Program that takes an input (2 text.txt) files, and counts the number of times the elements of File 1, appear in File 2, and print the result as shown. Please read the example below: Example: File A: BarcelonaDublinLas VegasLisbonLondonMadridNew YorkRioSan FransiscoShanghaiToronto File B: BarcalonaMadridMadridMadridMadridSan FransiscoTorontoVancouver Output after running the C Program using Binary Search Algorithm is: Barcelona is present 1 time/sDublin is present 0 time/sLas Vegas is present 0 time/sLisbon is present 0 time/sLondon is present 0 time/sMadrid is present 4 time/sNew York is present 0 time/sRio is present 0 time/sSan Fransisco is present 1 time/sShanghai is present 0 time/sToronto is present 1 time/sarrow_forwardWrite a JavaScript function named testGrade() that is able to do the following tasks:• First, pop up a prompt dialog box to ask the user to enter a test mark.• Use a while-loop to verify the user input. If the input value is less than 0 or more than100, a prompt dialog box will pop up to ask user re-enters the test mark. This promptdialog will keep popping until the user enters a valid test mark.• If the mark entered by the user is more than 70, an alert dialog box will be promptedwith the message “Pass!”, otherwise an alert dialog box will be prompted with themessage “Fail!”.arrow_forward
- In this challenge, the task is to debug the existing code to successfully execute all provided test files. Python supports a useful concept of default argument values. For each keyword argument of a function, we can assign a default value which is going to be used as the value of said argument if the function is called without it. For example, consider the following increment function: defincrement_by(n,increment=1):returnn+increment The functions works like this: >>>increment_by(5,2)7>>>increment_by(4)5>>> Debug the given function print_from_stream using the default value of one of its arguments. The function has the following signature: defprint_from_stream(n,stream) This function should print the first values returned by get_next() method of stream object provided as an argument. Each of these values should be printed in a separate line. Whenever the function is called without the stream argument, it should use an instance of EvenStream class defined in…arrow_forwardIn JavaScript, there are two types of comments: 1. Single-line comments start with // 2. Multi-line or inline comments start with /* and end with */ The input will be a sequence of //, /* and */. Every /* must have a */ that immediately follows it. To add, there can be no single-line comments in between multi-line comments in between the /* and */ . Create a function that returns true if comments are properly formatted, and false otherwise. Examples comments Correct("//////") → true // 3 single-line comments: ["//", "//", "//"] commentsCorrect("/**//**////**/") → true // 3 multi-line comments + 1 single-line comment: // ["/*", "*/", "/*", "*/", "//", "/*", "*/"] comments Correct("///*/**/") → false // The first /* is missing a */ comments Correct("/////") → false // The 5th / is single, not a double //arrow_forward02. Create a word enlister program, a program that will enlist the words found in the inputted sentence and it will display the count of vowels and consonants in each words. Sample run: WORD ENLISTER PROGRAM Enter a phrase/sentence: The apple, banana, and chico are fruits >>Words Enlisted: [1] THE - 3 Letter (s) - 2 Consonant (s) - 1 Vowel (s) [2] APPLE - 5 Letter (s) - 3 Consonant (s) - 1 Vowel (s) [3] BANANA - 6 Letter (8) - 3 Consonant (s) - 3 Vowel (s) [4] AND 3 Letter (s) 2 Consonant (s) -1 Vowel (s) [5] CHICO - 5 Letter (8) - 3 Consonant (s) - 1 Vowel (s) [6] ARE - 3 Letter (8) 1 Consonant (8) - 2 Vowel (s) [7] FRUITS - 6 Letter (s) - 4 Consonant (s) - 2 Vowel (8) >> Enter 'Y' to try again: n Program Terminatedarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education