What will be the result of following loop execution?
#include<iostream>
using namespace std;

int main(){
    int sum = 0;
    for(int i = 0; i<5; i++) sum += i,
    cout<<sum, 
    sum = 1;
    return 0;
}
Explanation
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
Cosmo
Sign Up Now
or Subscribe for future quizzes