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

  Develop a program that displays random numbers

Using a timer to generate a random number, develop a program that displays random numbers between 1 and 47 for your state's lottery.

  Create the roman.h and implement roman class in roman.cpp

Create the roman.h and implement the Roman class in roman.cpp. Make sure that you put in measures to prevent multiple inclusion of the header file. Test your implementation using task2a.cpp.

  Program to generate a star-based histogram for a quiz

Write a C++ program to generate a star-based histogram for a quiz (maximum score possible is 5) given to a class of N students, where N is an input from the user. Use arrays for computation.

  The actual solution of the equation shall be done

The actual solution of the equation shall be done by a function named equSolver(), which takes three coefficients as parameters and returns a structure of three fields: two roots (if they exist) and a boolean indicator, whether the roots do exist.

  Determine order in which constructors of class will execute

Suppose that an object of class three enters its scope, so the constructors of theses classes will execute. Determine the order in which the constructors of these classes will execute.

  Make a program to play lottery

make a program to play lottery. The program randomly generates a Lottery of a three-digit number( any number from 100 to 999), prompts the user to enter a three-digit number, and determines

  Main function to input twenty integers in given range

Write a main function to input 20 integers in range of 1-6, function should count number of times the numbers 2 and 5 occur. function must declare statics variables count2 and count5.

  Braces for blocks of code

C-- should have braces for blocks of code, an if statement, while statement, and a double, int, and character. Each statement ends with a semi-colon and you must have a main routine

  What output is produced by the following program

What output is produced by the following program?

  Function that will merge the contents

Write a function that will merge the contents of two sorted(ascending order) arrays of type double values, storing the result in an array output parameter (still in ascending order).

  A linked list of your song structure in cd

The CD object should have a data member that is a linked list of your song structure that you have in CD.  The CD class needs a function that allows it to add a song to the object, that function would then append the song to that instance of the link..

  Numbers until the user wants and in the end display

Write a C program to enter the numbers until the user wants and in the end display the product of numbers entered by the user. The program should terminate once the user enters the character 'n' and continue computing product if user enters 'y'

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