C++ language must use strings and c-strings similar to examples shown above task C++ language must use strings and c-str

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

C++ language must use strings and c-strings similar to examples shown above task C++ language must use strings and c-str

Post by answerhappygod »

C++ language
must use strings and c-strings similar to examplesshown above task
C Language Must Use Strings And C Strings Similar To Examples Shown Above Task C Language Must Use Strings And C Str 1
C Language Must Use Strings And C Strings Similar To Examples Shown Above Task C Language Must Use Strings And C Str 1 (34.47 KiB) Viewed 41 times
C Language Must Use Strings And C Strings Similar To Examples Shown Above Task C Language Must Use Strings And C Str 2
C Language Must Use Strings And C Strings Similar To Examples Shown Above Task C Language Must Use Strings And C Str 2 (14.53 KiB) Viewed 41 times
C++ language
must use strings and c-strings similar to examplesshown above task
#include #include #include using namespace std; int main () { //getline example for C-Strings char cStr[50]; cout << "Enter a line of input: "; cin.getline(cStr, 50); cout << "cStr = " << cStr << endl; //getline example for the String data type string str; cout << "Enter a line of input: "; getline (cin, str); cout << "str = " << str << endl; getline (cin, str, '?'); cout << "str = " << str << endl; // cin.get example for char input char ch; cout << "Enter a character: " cin.get(ch); cout << "ch = " << ch << endl; //getline returns a reference string s1, s2; cout << "Enter a line of input: "; getline (cin, s1) >> s2; cout << "s1 = " << s1 << endl; cout << "s2 = " << s2 << endl; // Mixing cin and getline int n; string line; cout << "Enter an integer and a string: "; cin >>n; //cin.ignore(50, '\n'); getline(cin, line); cout << "n = " << n << endl; cout << "line = " << line << endl; // Another version of getline // A string can behave like an array string str_arr; cout << "Enter a line of input: "; getline (cin, str_arr); for (int i = } cout << str_arr << " "; 0; i < str_arr.length(); i++) { } cout << endl; for (int i = 0; i < str_arr.length(); i++) { // accessing characters in a string using at() instead of [] cout << str_arr.at(i) << " "; return 0;
Task 2: Order Strings Write a program that takes three strings from user and prints them out in descending order. Sample Interaction: Enter 3 strings: Bob Alice Carol Strings in descending order: Carol Bob Alice
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply