Code
Output
VS Code
Run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream> #include <string> #include <vector> using namespace std; // C++ is compiled with g++ on the server, then run. cin really waits for you — // type your answer straight after the question and press Enter. int main() { string name; cout << "What is your name? "; cin >> name; cout << "Muraho, " << name << "!" << endl; vector<int> marks = {82, 74, 91, 68}; int total = 0; for (int mark : marks) { total += mark; } cout << "average: " << total / (double)marks.size() << endl; return 0; }
Output
Input prepared before running (optional)
Press Run to start your program.