CSC 7 S2

Cards (6)

  • FOR
    pre-test loop
    counter controlled
    WHILE
    pre-test loop
    counter controlled
    sentinel controlled
    DO-WHILE
    post-test loopcounter controlled • sentinel controlled
  • #include <iostream>
    using namespace std; int main() { int Counter=0, Sum=0, Num=0; cout << "Enter a number:"; cin >> Num; for (Counter=1; Counter<=Num; Counter=Counter+1) Sum=Sum+Counter; cout << "Sum of Numbers between 1 to << Num << "is"<< Sum; return 0;
    }
  • #include <iostream> using namespace std; int main() { int Number=0, Sum=0; cout << "Enter a number: "; cin >> Number;
    while (Number >= 0) { Sum Sum+ Number; cout << "Enter a number: "; cin >> Number; } cout << "\nThe sum is " << Sum << endl; return 0; }
  • #include <iostream> using namespace std; int main() { int Number=0, Sum=0; cout << "Enter a number: "; cin >> Number; while (Number >= 0) { Sum Sum+ Number; cout << "Enter a number: "; cin >> Number; } cout << "\nThe sum is " << Sum << endl; return 0; }
  • #include <iostream> using namespace std; int main() {
    int Counter = 1; do {
    cout << Counter << " ";
    Counter = Counter + 1;
    }
    while (Counter <= 5); return 0;
    }
  • #include <iostream> using namespace std;int main() {
    int Counter = 1;do {
    cout << Counter << " ";
    Counter = Counter + 1;
    }
    while (Counter <= 5);return 0;
    }