Statistics for What Does This C++ Code Do? - Click Quiz

Click here to take the quiz!

General Stats

  • This quiz has been taken 6 times
  • The average score is 9 of 12

Answer Stats

HintAnswer% Correct
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) r += a[i];
cout << r << endl;
Prints the sum of an array of integers
83%
string a;
getline(cin, a);
for(int i = a.length() - 1; i >= 0; i--) cout << a[i];
cout << endl;
Reads a string from stdin and prints it out in reverse
83%
string a, b;
getline(cin, a);
for(int i = 0; i < a.length(); i++) { if(a[i] >= 'A' && a[i] <= 'Z') b += a[i]; }
cout << b << endl;
Reads a string from stdin, discards all chars that aren't uppercase letters, then prints the new string
83%
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) r += a[i];
r /= sizeof(a) / sizeof(a[0]);
cout << r << endl;
Prints the average of an array of integers
67%
int a = 1, b = 1;
cout << a << ' ' << b << ' ';
for(int i = 3; i <= 10; i++) { int t = a; a = b; b = t; a = a + b; cout << a << ' '; }
cout << endl;
Prints the first 10 numbers in the Fibonacci sequence
67%
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) { if(a[i] % 2 == 0) r += a[i]; }
cout << r << endl;
Prints the sum of all even numbers in an array of integers
67%
int a[5] = {1, 2, 3, 4, 5}, r = 0;
for(int i = 0; i < 5; i++) { if(a[i] % 2 == 1) r += a[i]; }
cout << r << endl;
Prints the sum of all odd numbers in an array of integers
67%
string a;
getline(cin, a);
for(int i = 0; i < a.length(); i++) { if(i % 2 == 0) cout << a[i]; }
cout << endl;
Reads a string from stdin and prints every other character
67%
int a, b;
cin >> a >> b;
cout << a * b << endl;
Reads two integers from stdin and prints their product
67%
int a, b;
cin >> a >> b;
cout << a + b << endl;
Reads two integers from stdin and prints their sum
67%
int a, b;
cin >> a >> b;
cout << (a > b ? a : b) << endl;
Reads two integers from stdin and prints the maximum of those integers
67%
int a, b;
cin >> a >> b;
cout << (a < b ? a : b) << endl;
Reads two integers from stdin and prints the minimum of those integers
67%

Score Distribution

Percentile by Number Answered

Percent of People with Each Score

Your Score History

You have not taken this quiz