Question

Arrange the following lines into a working program, correct any errors you find in identifier names...

  1. Arrange the following lines into a working program, correct any errors you find in identifier names and/or incorrect program structure :

4str4 = “Programming in ”;

using namespace std;

str1 = "CSC"

cout << str6 << endl;

int main() ;

{

str2 = "201";

str3 = Second Semester CS;

#include<iostream>

  string str1, str2, str3, str4, str5, str6;

return 0;

str6 = str4 + str5 + " " + str1 + " " + str2 + " " + str3;

str5 = “C++”;

include<string>

}

Homework Answers

Answer #1
#include<iostream>
#include<string>
using namespace std;
int main() 
{
    string str1, str2, str3, str4, str5, str6;
    str1 = "CSC";
    str2 = "201";
    str3 = "Second Semester CS";
    str4 = "Programming in ";
    str5 = "C++";
    str6 = str4 + str5 + " " + str1 + " " + str2 + " " + str3;
    cout << str6 << endl;
    return 0;
}

Know the answer?
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
Similar Questions
Write up to three lines to explain the logic used behind those codes.        1) #include <iostream>...
Write up to three lines to explain the logic used behind those codes.        1) #include <iostream> #include <string> #include <fstream> #include <vector> #include <sstream> using namespace std; int main() {         ifstream infile("worldpop.txt");         vector<pair<string, int>> population_directory;         string line;         while(getline(infile, line)){                 if(line.size()>0){                         stringstream ss(line);                         string country;                         int population;                         ss>>country;                         ss>>population;                         population_directory.push_back(make_pair(country, population));                 }         }         cout<<"Task 1"<<endl;         cout<<"Names of countries with population>=1000,000,000"<<endl;         for(int i=0;i<population_directory.size();i++){                 if(population_directory[i].second>=1000000000){                        ...
read a text file into two parrall arrays. The file has a name and a grade...
read a text file into two parrall arrays. The file has a name and a grade here is what I am doing not working #include < iostream> #include < fstream> #include <string> usind namespace std; int main() { int const size =2; string names[size]; int age[size]; ifstream inputFile; inputFile.open("text.txt"); for (int i = 0; i <size; i++) { inputFile >> names[i]; inputFile>> age[i]; cout << age[i] << endl; cout << name[i] << endl; } inputFile.close(); return 0; }
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
Implement the body of the swap function using the indirection operator // finish this program so...
Implement the body of the swap function using the indirection operator // finish this program so that the values of // x and y are swapped in main(). #include <iostream> using namespace std; void swap(int* first, int* second) { // IMPLEMENT THIS FUNCTION // YOUR CODE GOES HERE } int main() { int x = 9; int y = 2; swap(&x, &y); cout << "x: " << x << endl; cout << "y: " << y << endl; // if...
11. 4.21 (What Does this Program Do?) What does the following program print? 1 // Exercise...
11. 4.21 (What Does this Program Do?) What does the following program print? 1 // Exercise 4.21: Mystery2.cpp 2 #include <iostream> 3 using namespace std; 4 5 int main() { 6 unsigned int count{1}; 7 8 while (count <= 10) { 9 cout << (count % 2 == 1 ? "****" : "++++++++") << endl; 10 ++count; 11 } 12 }
C++ program that Create a struct called car that has the following data members (variables): -...
C++ program that Create a struct called car that has the following data members (variables): - Color //color of the car - Model //model name of the car - Year //year the car was made - isElectric //whether the car is electric (true) or not (false) - topSpeed //top speed of the car, can be a decimal. code i have done struct not working properly. #include <iostream> using namespace std; struct Car { string color; string model_number; int year_model; bool...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC...
Instructions Write a program that produces the following output: CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC ++++++++++++++ +++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++ Note: The letter C in the output must be uppercase. #include <iostream> using namespace std; int main() {   cout<<"CCCCCCCCC ++ ++ CC ++ ++ CC ++++++++++++++ +++++++++++++++ CC +++++++++++++\n";   cout<<"+++++++++++++++ CC ++ ++ CCCCCCCCC ++ ++";   return 0; } this is my woek #include <iostream> using namespace std; int main() { cout<<"CCCCCCCCC ++...
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark...
There are 7 syntax errors and 3 semantic errors in the following code segment. Please mark them in the code and explain the reason briefly in place. #include<iostream> using namespace std; int main() { cout<<”Please input the radius (in integer): ”>>endl; int 1var = 10, var=20; double area = 40; cin<< var; //get an input of the radius and store in var float continue; float const pi = 2.64; pi += 0.5; do { cout<<”The radius is ”<<”var”<<endl; //print the...
Please fill in the blank bolded below that would be the best choice for this program....
Please fill in the blank bolded below that would be the best choice for this program. #include <iostream> using namespace std; const int size = 100000; class TheBig { public: double operator[](int index) const {return (theData[index]);} private: double theData[size]; }; void firstToBeThe( ______________________________________________________) { for (int i = 0; i <size; i++) cout << value[i] <<endl; } int main() { TheBig one; firstToBeThe(one); }
Please write variables and program plan (pseudocode) of the C++ programming code below: #include <iostream> #include...
Please write variables and program plan (pseudocode) of the C++ programming code below: #include <iostream> #include <cmath> using namespace std; int getWeight(); float deliveryCharge(int weight); void displayCharge(int weight); int main () {    displayCharge(getWeight());    return 0; }   int getWeight() {    int weight;    cout << "Enter package weight (oz): ";    cin >> weight;    return weight; } float deliveryCharge(int weight) {    if (weight > 16)    {        return (((weight - 16) / 4) *...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT