Write a C++ program to output the results for the following library functions. B
ID: 640307 • Letter: W
Question
Write a C++ program to output the results for the following library functions. Be sure to use proper formatting and appropriate comments in your code. (1) The length of the following string: C programming is fun! (2) Extract a substring from position 5 to position 9 from the following string: C++ programming is fun! (3) Determine the character at position 12 for the following string: C++ programming is fun! (4) Convert character W to its lowercase form. (5) Determine the absolute value for -38.49 (6) Determine (2.3) si show 4 characters after the decimal point) (7) Determine the square root of 13.29 (show 6 characters after the decimal point) Your output should be similar to the one shown as follows. The length of string C++ programming is fun! is 23 The substring of string C++ programming is fun! from positions 5 to 9 is rogra The character at position 12 for the string C++ programming is fun! is i The lowercase form of character W is w The absolute value of -38.49 is 38.49 (2.3) is 23.8882 The square root of 13.29 is 3.645545Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
int main() {
string s = "C++ Programming is fun";
cout << "length of String " << s << " is " << s.length() << endl;
cout << "Substring of String " << s << " from position 5 to 9 is " << s.substr(5,5) << endl;
cout << "Lower case form of character W is w." << endl;
cout << "power is " << pow(2.3,3.81) << endl;
cout << "square root of 13.29 is " << sqrt(13.29) << endl;
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.