Advertisement
gpric001

Untitled

Oct 3rd, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. /*
  2.   For the following problems determine the output of the programs.
  3.   It is possible the program has an error which would cause it
  4.   not to compile. If you think this is the case give at least one
  5.   reason why.
  6. */
  7.  
  8. //PROBLEM 1
  9. #include <iostream>
  10. #include <cmath>
  11.  
  12. using namespace std;
  13. int main(){
  14.  double x = 17.0;
  15.     double  z   =     3.22;
  16.     z =     pow(x,z);
  17.                 z   = sin(z);
  18.  z -= .0001; cout << static_cast<int>(z) << endl;
  19.  
  20.     return 0;
  21. }
  22.  
  23. //PROBLEM 2
  24. #include <iostream>
  25.  
  26. using namespace std;
  27.  
  28. int main(){
  29.     string statement = "The time is";
  30.     string oclock = " o'clock.";
  31.     int minute = 152;
  32.     int hour = 99;
  33.     minute %= (4 + 5) * 6;
  34.     hour = hour % 7;
  35.     cout << statement << endl << hour << ":" << minute << oclock << endl;
  36.      
  37.     return -2;
  38. }
  39.  
  40. //PROBLEM 3
  41. #include <iostream>
  42.  
  43. using namespace std;
  44.  
  45. int main(){
  46.     short x;
  47.     long w = 262143;
  48.     x = 0;
  49.     x += w;
  50.     cout << sizeof(x) << endl;
  51.     cout << sizeof(w) << endl;
  52.     cout << x << endl;
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement