+ 2
Can someone tell me why only even numbers are printed for the piece of code below???
#include <iostream> using namespace std; int main() { int i=1; int sum=0; while(i++<=10){ cout<<i<<" "; sum+=i; i++; } cout<<"and the sum is:::"<<sum; return 0; }
2 Respostas
+ 6
notice i++ happening twice. that makes the odds get skipped.
+ 5
because you are incrementing value of i twice