loops - n while(n>0 cout<<total<<endl for loop...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
C++ Loops Review While loop int n; cin>>n; int total=0; while(n>0) { total += n; n--; } cout<<total<<endl; do. ..while loop int n; cin>>n; int total=0; do { total += n;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n--; } while(n>0); cout<<total<<endl; for loop int n; int total=0; cin>>n; for(n;n>0;n--) { total +=n; } cout<<total<<endl;...
View Full Document

This note was uploaded on 04/02/2008 for the course COM SCI 31 taught by Professor Kinsey during the Fall '98 term at UCLA.

Ask a homework question - tutors are online