fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string s = "0123456789";
  7. cout << s.substr(3,7).substr(2).substr();
  8. return 0;
  9. }
  10.  
  11.  
  12. /*
  13. Select correct answer (single choice)
  14. It prints an empty string
  15. It prints 34567
  16. Compilation fails
  17. It prints 56789
  18.  
  19. What happens when you attempt to compile and run the following code?
  20.  
  21.   #include <iostream>
  22.   #include <string>
  23.   using namespace std;
  24.  
  25.   int main() {
  26.   string s1 = "aleph";
  27.   string s2 = "alpha";
  28.   string s;
  29.   s1.swap(s2);
  30.   s2.swap(s);
  31.   s.swap(s2);
  32.   cout << s2;
  33.   return 0;
  34.   }
  35.  
  36.  
  37.  
  38. Select correct answer (single choice)
  39. It prints aleph
  40. It prints an empty string
  41. It prints alpha
  42. Compilation fails
  43.  
  44. What happens when you attempt to compile and run the following code?
  45.  
  46.   #include <iostream>
  47.  
  48.   namespace SpaceA {
  49.   int A;
  50.   }
  51.  
  52.   namespace SpaceB {
  53.   int A;
  54.   }
  55.  
  56.   using namespace SpaceA, SpaceB;
  57.  
  58.   int main() {
  59.   SpaceA::A = SpaceB::A = 1;
  60.   std::cout << A + 1;
  61.   return 0;
  62.   }
  63.  
  64.  
  65.  
  66. Select correct answer (single choice)
  67. It prints 2
  68. It prints 1
  69. Compilation fails
  70. It prints 0
  71.  
  72. What happens when you attempt to compile and run the following code?
  73.  
  74.   #include <iostream>
  75.   using namespace std;
  76.  
  77.   namespace S {
  78.   int A = 1;
  79.   }
  80.  
  81.   namespace S {
  82.   int B = A + 2 ;
  83.   }
  84.  
  85.   int main(void) {
  86.   S::A = S::A + 1;
  87.   { using namespace S;
  88.   ++B;
  89.   }
  90.   cout << S::B << S::A;
  91.   return 0;
  92.   }
  93.  
  94.  
  95. Select correct answer (single choice)
  96. Compilation fails
  97. It prints 32
  98. It prints 22
  99. It prints 42
  100.  
  101. Exam
  102. Chapter 4 Assessment - CPA
  103.  
  104. What happens when you attempt to compile and run the following code?
  105.  
  106.   #include <iostream>
  107.   using namespace std;
  108.  
  109.   int main() {
  110.   float *ft[3] = { new float[3], new float[3], new float[3] }, *p;
  111.  
  112.   for(int i = 0; i < 3; i++) {
  113.   p = ft[i];
  114.   *p = p[1] = *(p + 2) = 10 * i;
  115.   }
  116.   cout << ft[1][1];
  117.   delete [] ft[0];
  118.   delete [] ft[1];
  119.   delete [] ft[2];
  120.   return 0;
  121.   }
  122.  
  123.  
  124. Select correct answer (single choice)
  125. It prints 10
  126. It prints 20
  127. It prints 30
  128. Compilation fails
  129.  
  130. What happens when you attempt to compile and run the following code?
  131.  
  132.   #include <iostream>
  133.   using namespace std;
  134.  
  135.   int main() {
  136.   short s = 1;
  137.   int i = 2;
  138.   long l = 3;
  139.   float f = 4.4;
  140.   double d = 6.6;
  141.  
  142.   cout << s/i + f/i + d/s;
  143.   return 0;
  144.   }
  145.  
  146.  
  147.  
  148. Select correct answer (single choice)
  149. It prints 6.6
  150. Compilation fails
  151. It prints 4.4
  152. It prints 8.8
  153.  
  154. What happens when you attempt to compile and run the following code?
  155.  
  156.   #include <iostream>
  157.   using namespace std;
  158.  
  159.   int main() {
  160.   short s = 1;
  161.   int i = 2;
  162.   long l = 3;
  163.   float f = 4.4;
  164.   double d = 6.6;
  165.  
  166.   cout << s/float(i) + int(f)/i + long(d)/s;
  167.   return 0;
  168.   }
  169.  
  170.  
  171.  
  172. Select correct answer (single choice)
  173. Compilation fails
  174. It prints 8.8
  175. It prints 8.5
  176. It prints 8.0
  177.  
  178. What happens when you attempt to compile and run the following code?
  179.  
  180.   #include <iostream>
  181.   using namespace std;
  182.  
  183.   int main() {
  184.   int i = 2;
  185.   float f = 5.8;
  186.  
  187.   f = (int)f;
  188.   i = (float) i;
  189.   cout << f/i;
  190.   return 0;
  191.   }
  192.  
  193.  
  194.  
  195. Select correct answer (single choice)
  196. It prints 2
  197. It prints 3
  198. Compilation fails
  199. It prints 2.5
  200.  
  201. What happens when you attempt to compile and run the following code?
  202.  
  203.   #include <iostream>
  204.   using namespace std;
  205.  
  206.   int main() {
  207.   int i = 2;
  208.   float f = 4.4;
  209.  
  210.   cout << f % float(i);
  211.   return 0;
  212.   }
  213.  
  214.  
  215.  
  216. Select correct answer (single choice)
  217. It prints 0
  218. Compilation fails
  219. It prints 0.2
  220. It prints 2
  221.  
  222. What happens when you attempt to compile and run the following code?
  223.  
  224.   #include <iostream>
  225.   #include <string>
  226.   using namespace std;
  227.  
  228.   int main() {
  229.   string s = "a";
  230.  
  231.   cout << s + "b" + "c";
  232.   return 0;
  233.   }
  234.  
  235.  
  236.  
  237. Select correct answer (single choice)
  238. It prints abc
  239. It prints ab
  240. Compilation fails
  241. It prints a
  242.  
  243. What happens when you attempt to compile and run the following code?
  244.  
  245.   #include <iostream>
  246.   #include <string>
  247.   using namespace std;
  248.  
  249.   int main() {
  250.   string s = "0123456789";
  251.   cout << s.substr(3,7).substr(2).substr();
  252.   return 0;
  253.   }
  254.  
  255.  
  256.  
  257. Select correct answer (single choice)
  258. It prints an empty string
  259. It prints 34567
  260. Compilation fails
  261. It prints 56789
  262.  
  263. What happens when you attempt to compile and run the following code?
  264.  
  265.   #include <iostream>
  266.   #include <string>
  267.   using namespace std;
  268.  
  269.   int main() {
  270.   string s1 = "aleph";
  271.   string s2 = "alpha";
  272.   string s;
  273.   s1.swap(s2);
  274.   s2.swap(s);
  275.   s.swap(s2);
  276.   cout << s2;
  277.   return 0;
  278.   }
  279.  
  280.  
  281.  
  282. Select correct answer (single choice)
  283. It prints aleph
  284. It prints an empty string
  285. It prints alpha
  286. Compilation fails
  287.  
  288. What happens when you attempt to compile and run the following code?
  289.  
  290.   #include <iostream>
  291.  
  292.   namespace SpaceA {
  293.   int A;
  294.   }
  295.  
  296.   namespace SpaceB {
  297.   int A;
  298.   }
  299.  
  300.   using namespace SpaceA, SpaceB;
  301.  
  302.   int main() {
  303.   SpaceA::A = SpaceB::A = 1;
  304.   std::cout << A + 1;
  305.   return 0;
  306.   }
  307.  
  308.  
  309.  
  310. Select correct answer (single choice)
  311. It prints 2
  312. It prints 1
  313. Compilation fails
  314. It prints 0
  315.  
  316. What happens when you attempt to compile and run the following code?
  317.  
  318.   #include <iostream>
  319.   using namespace std;
  320.  
  321.   namespace S {
  322.   int A = 1;
  323.   }
  324.  
  325.   namespace S {
  326.   int B = A + 2 ;
  327.   }
  328.  
  329.   int main(void) {
  330.   S::A = S::A + 1;
  331.   { using namespace S;
  332.   ++B;
  333.   }
  334.   cout << S::B << S::A;
  335.   return 0;
  336.   }
  337.  
  338.  
  339. Select correct answer (single choice)
  340. Compilation fails
  341. It prints 32
  342. It prints 22
  343. It prints 42
  344. */
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
56789