Shows the effect of the preceding statements

Assignment Help C/C++ Programming
Reference no: EM13339789

The following program shows the effect of the preceding statements.
//Example string operations
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name = "William Jacob"; //Line 1
string str1, str2, str3, str4; //Line 2
cout << "Line 3: Name = " << name << endl; //Line 3
str1 = "Hello There"; //Line 4
cout << "Line 5: str1 = " << str1 << endl; //Line 5
str2 = str1; //Line 6
cout << "Line 7: str2 = " << str2 << endl; //Line 7
str1 = "Sunny"; //Line 8
str2 = str1 + " Day"; //Line 9
cout << "Line 10: str2 = " << str2 << endl; //Line 10
str1 = "Hello"; //Line 11
str2 = "There"; //Line 12
str3 = str1 + " " + str2; //Line 13
cout << "Line 14: str3 = " << str3 << endl; //Line 14
str3 = str1 + " " + str2; //Line 15
cout << "Line 16: str3 = " << str3 << endl; //Line 16
str1 = str1 + " Mickey"; //Line 17
cout << "Line 18: str1 = " << str1 << endl; //Line 18
str1 = "Hello there"; //Line 19
cout << "Line 20: str1[6 ] = " << str1[6 ]
<< endl; //Line 20
str1[6] = "T"; //Line 21
cout << "Line 22: str1 = " << str1 << endl; //Line 22
//String input operations
cout << "Line 23: Enter a string with "
<< "no blanks: "; //Line 23
cin >> str1; //Line 24
char ch; //Line 25
cin.get(ch); //Read the newline character; Line 26
cout << endl; //Line 27
cout << "Line 28: The string you entered = "
<< str1 << endl; //Line 28
cout << "Line 29: Enter a sentence: "; //Line 29
getline(cin, str2); //Line 30
cout << endl; //Line 31
cout << "Line 32: The sentence is: " << str2
<< endl; //Line 32
return 0;
}

Reference no: EM13339789

Questions Cloud

State whether the following are valid switch statements : State whether the following are valid switch statements. If not, explain why. Assume that n and digit are int variables.
Calculate the wavelength of the interfering waves : Two sinusoidal waves traveling in opposite directions interfere to produce a standing wave with the wave function y = (1.00) sin(0.800x) cos(300t), Determine the wavelength of the interfering waves
What are the operating risks of the company : What are the operating risks of the company and what is the financial risk of the company (the debt to total capitalization ratio)?
What is the range of wavelengths of this sound in air : Bats emit a wide variety of sounds, one type emits pulses of sound having a frequency between 39kHz and 78kHz. What is the range of wavelengths of this sound in air
Shows the effect of the preceding statements : The following program shows the effect of the preceding statements.
Compute the unit target cost per calculator : Calcutron Company is contemplating introducing a new type of calculator to complement its existing line of scientific calculators.
Assume there is no foreign trade and the economy : Assume there is no foreign trade and the economy is in equilibrium. If actual investment is greater than desired investment then it is most likely that?
Determine how fast must the particle be traveling : A particle of mass m0 is given a kinetic energy equal to one-fourth its rest-mass energy. How fast must the particle be traveling
Write a program that will input the name of five students : Write clearly with documentations where necessary as you write the program to solve the following problem.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Afunction that raises an integer to a positive integer

Write a function that raises an integer to a positive integer power. Call the function x_to_the_n, taking two integer arguments x and n.

  Write and run a c++ program that computes and displays

A machine purchased for $28,000 is depreciated at a rate of $4,000 a year for 7 years. Write and run a C++ program that computes and displays a depreciation table for 7 years.

  A perfect solution is impossible or too expensive

Optimization is often encountered in engineering problems. More often than not, a perfect solution is impossible or too expensive to find and implement. Therefore, we resort to sub-optimal, yet useful, solutions. This assignment tackles a classical p..

  Write a function named vowelwords

Write a function named vowelwords(), that reads the file text1.txt and create a new file named text2.txt, which shall contain only those words from the file text1.txt which don’t start with an uppercase vowel(i.e., with ‘A’,’E’,’I’,’O’,’U’)

  Implement the readlog function

Implement the readLog function below, which is to (1) read the file, (2) populate a vector for each column, and (3) return the number of lines found.

  Write a method that accepts a string

Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display - "ytivarg". Demonstrate the method in a program that asks the user to input..

  Class named realestate that has data members

Create a class named RealEstate that has data members to hold the price of a house, the number of bedrooms, and the number of baths. Member functions include overloaded insertion and extraction operations

  Write program to input series of hourly temperatures

Create and write a c++ program which inputs series of 24 hourly temperatures from file, and outputs bar chart (using stars) of temperatures for the day.

  Write c++ program to create a bar chart showing the average

Write a c++ program to create a bar chart showing the average monthly mean temperature for College Station from 2004 to 2013.

  Write a menu driven program for an online beef

Write a menu driven program for an online beef distribution company. There are 8 different

  Program to compute diameter in centimeters of a steel rod

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  Compares the number of possible sequences

A c++ program that compares the number of possible sequences of the length L that can be generated uinder the following assumptions. Given an alphabet of size N=9. The program must output a formatted list comparing the number of possible sequences..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd