Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /* Your solution goes here */
- void CoordTransform(int xVal, int yVal, int& xValNew, int& yValNew)
- {
- xValNew = (xVal + 1) * 2;
- yValNew = (yVal + 1) * 2;
- }
- int main() {
- int x;
- int y;
- int xValNew;
- int yValNew;
- cout<<"Enter x coord:";
- cin>>x;
- cout<<"\nEnter y coord:";
- cin>>y;
- CoordTransform(x, y, xValNew, yValNew);
- cout << "\n("<<x<<", "<<y<<") becomes " << "(" << xValNew << ", " << yValNew << ")" << endl;
- return 0;
- }
- --------------------------
- //M19-02: Passing by Reference: Checking string length and capitalization
- #include <iostream>
- #include <stdio.h>
- #include <ctype.h>
- using namespace std;
- //FIXME: Modify function below to use pass by reference
- bool message(string& msg)
- {
- cout << msg << endl;
- if(msg.length() > 10)
- return(true);
- return(false);
- }
- bool isCapital(string msg)
- {
- if(isupper(msg.at(0)))
- return (true);
- return (false);
- }
- int main(int argc, char **argv)
- {
- string userString;
- cout<<"Enter your message:"<<endl;
- getline(cin, userString);
- //FIXME: Modify code below to print state of capitalization
- bool msg_is_long = message(userString);
- bool iscap = isCapital(userString);
- if(msg_is_long)
- cout << "That was a long message." << endl;
- else
- cout << "That was a short message." << endl;
- if(iscap)
- cout << "The message was properly capitalized." << endl;
- else
- cout << "The message was not properly capitalized." << endl;
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement