Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- For the following problems determine the output of the programs.
- It is possible the program has an error which would cause it
- not to compile. If you think this is the case give at least one
- reason why.
- */
- //PROBLEM 1
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main(){
- double x = 17.0;
- double z = 3.22;
- z = pow(x,z);
- z = sin(z);
- z -= .0001; cout << static_cast<int>(z) << endl;
- return 0;
- }
- //PROBLEM 2
- #include <iostream>
- using namespace std;
- int main(){
- string statement = "The time is";
- string oclock = " o'clock.";
- int minute = 152;
- int hour = 99;
- minute %= (4 + 5) * 6;
- hour = hour % 7;
- cout << statement << endl << hour << ":" << minute << oclock << endl;
- return -2;
- }
- //PROBLEM 3
- #include <iostream>
- using namespace std;
- int main(){
- short x;
- long w = 262143;
- x = 0;
- x += w;
- cout << sizeof(x) << endl;
- cout << sizeof(w) << endl;
- cout << x << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement