//please can someone explain the output 4 8 12,why is it so? Thanks
int count = 0;
do
{
for( int i = 0; i < 4; i++ )
count++;
cout << count << ‘ ‘;
} while ( count < 10 );
PulsarScript
0
Junior Poster
Recommended Answers
Jump to PostIt's because for loop increments count by 4 each time
It's the same as if you wroteint count = 0; do { count = count+4; cout << count << ‘ ‘; } while ( count < 10 );
Jump to Postbasically for loop runs
count++
4 times
because i < 4
and each time
count++ adds one number to previous value of count
All 8 Replies
111100/11000
111100/11000
111100/11000
PulsarScript
0
Junior Poster
Moschops
683
Practically a Master Poster
Featured Poster
PulsarScript
0
Junior Poster
vmanes
1,165
Posting Virtuoso
PulsarScript
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.