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++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (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)
- What output will be produced when the following lines are executed, assuming the file list.dat contains data shown (and assuming the lines are embedded in a complete and correct program with the proper include directives)? Write your answer in the box below. The file list.dat contains the following three numbers, and nothing more. 1 2 3 Output Display ifstream ins; ins.open (“list.dat”); int count = 0, next; while (ins >> next) { count++; cout << setw(next) << next << endl ;} ins.close (); cout << setw(++count) << count;arrow_forwardThe dirname utility treats its argument as a pathname and writes to standard output the path prefix—that is, everything up to but not including the last component: $ dirname a/b/c/d a/b/c If you give dirname a simple filename (no / characters) as an argument, dir-name writes a . to standard output: $ dirname simple . Implement dirname as a bash function. Make sure it behaves sensibly when given such arguments as /.arrow_forwardAfter every word on a line is spellchecked, it should be written to an output file called checked.txt. The arrangement of words on lines should be the same in the document and in checked.txt. The difference between the document and checked.txt is that in checked.txt each word is in lowercase and there is no punctuation. Also, some words might be changed by the spellcheck process. For example, suppose the document contains the following: The Hunter Moon waxed round in the night sky, and put to flight all the lesser stars. But low in the South one star shone red. Then checked.txt will contain: the hunter moon waxed round in the night sky and put to flight all the lesser stars but low in the south one star shone red (In a real spellchecker, the output will be in the same case as the original, and all punctuation will be retained. For simplicity, we will not worry about case and punctuation.) How to Process Words Which Are Not in the Dictionary The spellcheck method also needs to handle…arrow_forward
- Modify the program 11-10 from pages 753-755 as follows: 1. To Length class files (Length.h and Length.cpp) add the operator overload for stream insertion (<<) and stream extraction (>>) from page 759. You should not use the modified version of class Length from page 759 because it contains more operator overloads. Instead of typing you can use copy/paste from Length1.h and Length1.cpp respectively. 2. In main() replace the lines 11-16 with appropriate usage of stream extraction overload (>>) to change "first" and "second" objects with values inputted by the end user. 3. In main(), replace the output on lines 21,22 and 25,26 with appropriate usage of stream insertion (<<) operator. The resulting output should be identical with the unmodified version of the program. 11-10: // This program demonstrates the Length class's overloaded // +, -, ==, and < operators. #include <iostream> #include "Length.h" using namespace std; int main() { Length first(0),…arrow_forwardOur requirement is to keep information of students who are taking “Introduction to Python” in Fall-2021 in a text file named ‘Students.txt’. The first line of text in this file will be header line as follows Write a python code that: Takes StudentID from user as input in a variable ‘inputID’, reads the file line by line and displays the header line and student information when inputID is found in Students.txt, otherwise display a message ‘Record not found in Students.txt’arrow_forwardWrite a cpp program that contains class “candidate”. A candidate has a name, number of electoral votes and number of popular votes.In your program, write a function that reads an input file containing elections results using input file stream and output to the console the name of the winner, his electoral votes and his popular votes.Your function should be prominent to faulty data; for example, if the number of votes for one of the candidates was a negative number, the function should exit and print a proper error message on the screen (You must use exceptions to do this)arrow_forward
- Question 3 Explain the difference between a script file and a function file i) Write a program using MATLAB that calculates the average, å = 1 N x x1 N i =1 and the standard deviation for a set of values (X), S = Make a script file ‘date.m’ with which the user can call up de desired date. How to solve the problem Ask the user (with the command >> input if he/she wants to know the date (1=yes, 2=no). - If the answer is ‘yes’ the date must be displayed (>> date). If the answer is ‘no’ display on the screen that the user does not want to know the date (>> disp) Write the m-file in MATLAB. Given the function prototype, Function [out] = examfcn (in) Write four (4) different calls to the function, each of…arrow_forwardHello, there is currently an error in my code where I am told the following: Traceback (most recent call last): File "C:/Users/thepe/PycharmProjects/CPE101Labs/Dunder Mifflin/Employee Managment/employee.py", line 1, in <module> class employee: File "C:/Users/thepe/PycharmProjects/CPE101Labs/Dunder Mifflin/Employee Managment/employee.py", line 67, in employee employeeList.append(employeeList("Michael", 45, "Manager"))TypeError: 'list' object is not callable Here's my code: class employee:def __init__(self, name, age, position):self.name = nameself.age = ageself.position = positiondef display_employees(listOfEmployees):print()print("Employees in Dunder Mifflin are:")print()for item in listOfEmployees:print(item.name + ",", str(item.age) + ",", item.position)def allocate_department(listOfEmployees):allocatedList = []managementList = []salesList = []accountantList =[]for employee in listOfEmployees:if employee.positon == "Manager" or "Manager" in…arrow_forwardWhat would be the printout of the following code if the same file.txt was used as above? int main() { fstream file("file.txt", ios::in); char ch; file.get(ch); while (!file.eof()) { cout << ch << " "; file.get(ch); } file.close(); return 0;} Group of answer choices I have a dream. I h a v e a d r e a m . Ihaveadream. I have a dream.I have a dream.arrow_forward
- Trace the following Code and then print the output. msg db 'hello world$' newline db 10,13,'$' buffer db 10 dup mov ah,9 mov dx,offset msg int 21h ;new line mov ah,9 mov dx, offset newline int 21h ;enter a string from the keyboard lea dx,buffer mov ah,0ah int 21h ;new line mov ah,9 mov dx,offset newline int 21h ;adding the $ symbol at the end of the string mov bx,0 mov bl,buffer[1] mov buffer[bx+2],'$' mov ah,9 mov dx,offset buffer+2 int 21harrow_forwardCan this code be made to news all the way to the cheese and displayed with a "*" instead of finding the number? In C++ #include <iostream> using namespace std; int n = 5, m = 5; int visited[5][5]; int x_corr[] = {1, -1, 0, 0}; int y_corr[] = {0, 0, 1, -1}; bool checkBoundary(int i, int j) { return (i >= 0 && i < n && j >= 0 && j < m); } int returnNumberPaths(int i, int j) { if (i == n - 1 && j == m - 1) { return 0; } int ans = 0; visited[i][j] = 1; for (int k = 0; k < 4; k++) { int newi = i + x_corr[k]; int newj = j + y_corr[k]; if (checkBoundary(newi, newj) && !visited[newi][newj]) { ans += returnNumberPaths(newi, newj); } } return ans + 1; } int main(int argc, char *argv[]) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { visited[i][j] = 0; }…arrow_forwardWrite a parallel version of the program below using MPI. The output should be essentially the same as the sequential version; the only exception is that the perfect numbers might be found in a different order. Your program should report the total number of perfect numbers found and the time, exactly as the sequential version does. #include <stdio.h> #include <stdlib.h> #include <sys/time.h> double mytime() { struct timeval t; gettimeofday(&t, NULL); return t.tv_sec + t.tv_usec/1000000.0; } _Bool is_perfect(int n) { if (n < 2) return 0; int sum = 1, i = 2; while (1) { const int i_squared = i*i; if (i_squared < n) { if (n%i == 0) sum += i + n/i; i++; } else { if (i_squared == n) sum += i; break; } } return sum == n; } int main(int argc, char * argv[]) { int num_perfect = 0; double start_time = mytime(); if (argc != 2) { printf("Usage: perfect.exec bound\n"); exit(1); } int bound = atoi(argv[1]); for (int i=1; i<=bound; i++) { if (i%1000000 ==…arrow_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