What will be the result of following loop execution?
using namespace std;

int main(){
    int sum = 0;
    for(int i = 0; i<5; i++) sum += i,
    sum = 1;
    return 0;
Since the "comma" operator has been used, few lines will be executed in the loop.

there are no correct answer. according to this code result will be "12222"

2019 Oct 28, 7:24:47 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C++ quizzes
Sign Up Now
or Subscribe for future quizzes