1. string s = “Weekly Assignment 4”; if(s.empty()) cout<<”Empty”; else cout<<”No
ID: 3667914 • Letter: 1
Question
1.
string s = “Weekly Assignment 4”;
if(s.empty())
cout<<”Empty”;
else
cout<<”Not Empty”;
2.
string s = “Weekly Assignment 4”;
cout<<s.substr(1,7);
3.
string s = “Weekly Assignment 4”;
cout<<(s+”CMPSC101”);
4.
string s = “Weekly Assignment 4”;
s.replace(3,4,"pppp");
cout<<s;
5.
#include <iostream>
#include <string>
using namespace std;
int main()
{
char c = 'F';
if( (c >= 'E') && (c+1 == 'H') )
cout<<"First condition satisfied";
else if ( (c == 'G') || (c < 'T') )
cout<<"Second condition satisfied";
else if ( ((c != 'F') || (c < 'S')) && (c >= 'A') )
cout<<"Third condition satisfied";
else
cout<<"None of the conditions were satisfied";
return 0;
}
Explanation / Answer
1.
Not Empty
2.
Weekly
3.
Weekly Assignment 4CMPSC101
4.
WeeppppAssignment
5.
Third condition satisfied
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.