#include #include using namespace std; void BasicForLoops(); void AverageGrades(); bool WhileLoopExample(); void LoopWhileExample(); int main() { //BasicForLoops(); //AverageGrades(); /*bool result =WhileLoopExample(); if (result) { cout << "Welcome to the program" << endl; } else { cout << "Sorry, You FAIL" << endl; }*/ LoopWhileExample(); system("PAUSE"); } void BasicForLoops() { int MyArray[10]; int i =0; //write to the array for( i =0; i<10;i++) { MyArray[i] =i*3-2; }//end for cout << i << endl; //read from the array for(i=0; i<10;i++) { cout << MyArray[i] << endl; } cout<<"Enter how many loops you want to do"; int loops; cin >> loops; for (int x=0; x < loops; x++) { cout << "Hello" << endl; } }//end function void AverageGrades() { int number; cout << "How many grades to enter" << endl; cin >> number; int *ptrArray= new int[]; ptrArray[number]; for (int i=0; i < number; i++) { cout<<"Enter a grade : "; cin >> ptrArray[i]; cout << endl; } int total=0; for (int i=0; i < number; i++) { total += ptrArray[i]; } double average=double(total) /number; cout << "Average grade is: " << average << endl; delete ptrArray; } bool WhileLoopExample() { bool authenticated=false; int counter=0; while (authenticated==false && counter < 3) { string username, password; cout << "enter your username" << endl; getline(cin, username); cout << "Enter Your password" << endl; getline(cin, password); //&& and, || or if (username=="Michelle Brown" && password=="password") { authenticated=true; }//end if counter ++; } // end while return authenticated; }//end function void LoopWhileExample() { int counter=1; do { counter++; cout << counter << endl; } while (counter < 1); }