Question

Please help me with these questions. thanks! Question 1: Identify the lines in the code segment...

Please help me with these questions. thanks!

Question 1:

Identify the lines in the code segment below that contain syntax errors. You may assume all necessary libraries have been included. Evaluate each statement as if all previous statements are correct

                ofstream venom.open(“symbiote.txt”, ios::app);

ifstream carnage;

                carnage.open(“symbiote2.txt:; ios::in | ios::out)

                venom.seekp(-10L, ios::beg);

cout << carnage.tellg(0);

venom << “HI. I’m Eddie Brock> Can Peter come out and play?” << endl;

Answers:

                Connecting the output stream to the file

                Connecting the input stream to the file

                Moving the file pointer in the output file

Accessing the file pointer position in the input file

                Writing to the output file

Question 2:

What is the output of the following code segment?

                char villian1[20], villain2[20];

                strcpy(villain1, “Sandman”);

                strcpy(villain2, “Mysterio”);

                f(strcmp(villain1, villain2) < 0)

                                Cout << villain1;

                Else if(strcmp(villain1, villain2) > 0)

                                Cout << villain2;

                Else

                                Cout << “same”;

Answers:

                Mysterio

                Sandman

                same

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans.

ofstream venom.open(“symbiote.txt”, ios::app);

Connecting the output stream to the file

Explanation: we have not declare ofstream object before

Accessing the file pointer position in the input file

cout << carnage.tellg(0);

Explanation: tellg(void) it do not receive any parameter

Ans 2)

Mysterio

Explanation:

Here, sandman > mysterio so output greater than 0 according to strcmp since s come after m in dictionary order

here villian1 = sandman, villian2 = mysterio

if(strcmp(sandman ,mysterio) > 0)//true only

cout<< villian2//mysterio

therefore, output is mysterio

/* PLEASE UPVOTE */

Add a comment
Know the answer?
Add Answer to:
Please help me with these questions. thanks! Question 1: Identify the lines in the code segment...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Programming question For this exercise, you will receive two string inputs, which are the names...

    C++ Programming question For this exercise, you will receive two string inputs, which are the names of the text files. You need to check if the input file exists. If input file doesn't exist, print out "Input file does not exist." You are required to create 4 functions: void removeSpace (ifstream &inStream, ofstream &outStream): removes white space from a text file and write to a new file. If write is successful, print out "Text with no white space is successfully...

  • Can some help me with my code I'm not sure why its not working. Thanks In...

    Can some help me with my code I'm not sure why its not working. Thanks In this exercise, you are to modify the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard input device (keyboard) and outputs the results on the standard output device (screen). The program can process only 20 numbers. Rewrite the program to incorporate the following requirements: a. Data to the program is input from a file of an...

  • what would be the pseudocode for my source code? Tools Plugins DoxyBlocks Settings Help program.cpp Code...

    what would be the pseudocode for my source code? Tools Plugins DoxyBlocks Settings Help program.cpp Code Blocks 16.01 e Edt View Search Project Build Debug Fortran wwSmith Tools Start here WOODSC program.cpp x #include <cstdlib> #include <iostream> include <string> Pinelude <stream include <string> using namespace std: int main(int argc, char argv11) 10 el itatre in stream: de lared to streamchele detasan input- string filein, fileout, key: Stringa tes are created to hold the nates and key Val of stream out...

  • Code in C++: Please help me fix the error in function: void write_account(); //function to write...

    Code in C++: Please help me fix the error in function: void write_account(); //function to write record in binary file (NOTE: I able to store data to a txt file but however the data get error when I try to add on data the second time) void display_all(); //function to display all account details (NOTE: This function is to display all the info that save account.txt which is ID, Name, and Type) void modify_account(int); //function to modify record of file...

  • C++ Can someone please help me with this problem- commenting each line of code so I...

    C++ Can someone please help me with this problem- commenting each line of code so I can understand how to solve this problem using the C++ programming language? I really need help understanding how to create a file for the program to read. Do I create the file in Visual basic or create a text file? I have the code, just need to know how to create the file for it to read. #include<fstream> #include<iostream> using namespace std; int main()...

  • /* BEGIN - DO NOT EDIT CODE */ // File: main.cpp #include "LoginAccount.h" #include "RegisteredLoginAccount.h" #include...

    /* BEGIN - DO NOT EDIT CODE */ // File: main.cpp #include "LoginAccount.h" #include "RegisteredLoginAccount.h" #include "GuestLoginAccount.h" #include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; //prototypes and constants const int ARRAY_SIZE = 20; using number_of_records_t = int; //Function Declarations. void readAccountsFromFile(ifstream& fin, RegisteredLoginAccount registeredAccounts[], number_of_records_t& registeredLength, GuestLoginAccount guestAccounts[], number_of_records_t& guestLength); bool openFileForInput(ifstream& ifs, const string& filename); bool openFileForOutput(ofstream& ofs, const string& filename); void writeAccountsToFile(ofstream& ofs, RegisteredLoginAccount registeredAccounts[], const number_of_records_t registeredLength, GuestLoginAccount guestAccounts[], const number_of_records_t guestLength); void writeAccountToFile(ofstream&...

  • I want to change this code and need help. I want the code to not use...

    I want to change this code and need help. I want the code to not use parallel arrays, but instead use one array of struct containing the data elements, String for first name, String for last name,Array of integers for five (5) test scores, Character for grade. If you have any idea help would be great. #include #include #include #include using namespace std; const int NUMBER_OF_ROWS = 10; //number of students const int NUMBER_OF_COLUMNS = 5; //number of scores void...

  • Please help the out keeps printing twice #include #include #include #include #include using namespace std; /**...

    Please help the out keeps printing twice #include #include #include #include #include using namespace std; /** * Function to calculate the future value and return the same */ double calculateFutureValue(double presentValue, double interestRate, int months) {    double futureValue = (double)presentValue * pow((1 + interestRate), months);    return futureValue; } /** * Function to read the input file and assign the value to the variables */ unsigned int readfile(ifstream &inF, double &presentValue, double &interestRate, int &months) {    inF >>...

  • Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters...

    Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters student first name, 10 characters middle name, 20 characters last name, 9 characters student ID, 3 characters age, in years (3 digits) 2- Open the input file. Check for successful open. If the open failed, display an error message and return with value 1. 3- Use a pointer array to manage all the created student variables.Assume that there will not be more than 99...

  • C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally...

    C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally compile. Below is a picture of the error messages. //main.cpp //Semester Project //Created by J---on 5/6/2019 #include <iostream> #include <fstream> #include <string> #include <sstream> #include <bits/stdc++.h> using namespace std; void instructions(); //displays program details and instructions void openFile(); void takeInput(int*); void switchBoard(int*); struct price {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT