Lab 11.docx - HIBA AKHTER | 02-134192-069 Lab 11 Task 01 Write a C that contain two strings String1= \u201cThis program is to test several string

Lab 11.docx - HIBA AKHTER | 02-134192-069 Lab 11 Task 01...

This preview shows page 1 - 4 out of 10 pages.

HIBA AKHTER | 02-134192-069 Lab 11 Task 01: Write a C++ that contain two strings: String1= “This program is to test several string functions”. String2 = “Testing” Perform following operations on these strings: Print a new string “Testing: This program is to test several string function” using concatenation of string 1 and strin2. Find the size of string1 and string2 using string function. Extract word “program” from string1 using string function. Insert a word “Program” in string2 like “Testing Program” using string function. Replace the word “Program” in string1 with string2 using string function. Delete word “program” from string1 using string function Source code: #include <iostream> #include <iostream> using namespace std; int main() { string str1 = "this program is to test several string functions" ; string str2 = "testing" ; cout << "******************************" << endl; cout << "" << endl; cout << " CONCATENATION OF STRING 1 AND 2" << endl; cout << "" << endl; cout << "******************************" << endl; str2.append( ":" ); cout << str2.append(str1) << endl; cout << "******************************" << endl; cout << "" << endl; cout << " SIZE OF STRING 1 AND 2" << endl; cout << "" << endl; cout << "******************************" << endl; cout << str1.length() << endl; cout << str2.length() << endl; cout << "******************************" << endl; P a g e 1 | 10
Image of page 1
HIBA AKHTER | 02-134192-069 cout << "" << endl; cout << " EXTRACTING WORD FROM STRING 1" << endl; cout << "" << endl; cout << "******************************" << endl; cout << str1.substr(5, 7) << endl; cout << "******************************" << endl; cout << "" << endl; cout << " INSERTING WORD IN STRING 2" << endl; cout << "" << endl; cout << "******************************" << endl; str2 += "program" ; cout << str2.append( "" ) << endl; cout << "******************************" << endl; cout << "" << endl; cout << "REPLACE WORD IN STRING 1 WITH STRING 2" << endl; cout << "" << endl; cout << "******************************" << endl; cout << str2.replace(5, 7, str1) << endl; cout << "******************************" << endl; cout << "" << endl; cout << "DELETING WORD 'PROGRAM' IN STRING 1" << endl; cout << "" << endl; cout << "******************************" << endl; cout << str1.erase(5, 7) << endl; return 0; } Coding: P a g e 2 | 10
Image of page 2
HIBA AKHTER | 02-134192-069 Task 02 Write a C++ program that maintain record of students. Student contains following details:
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 10 pages?

  • Summer '15

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes