### Urgent help needed for an assignment

Hey Guys,
Im workin on an assignment to be handed over soon and Im really stuck with identifying sequence, selection and iteration in the following code. Could someone identify these three for me? And a simple explanation of why they are used in this instance would be greatly appreciated.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207`` ``````#include #include #include using namespace std; string nameArray[10]; //to store student names int markArray[10]; //to store student marks void ExchangeSort()//sorting the marks in descending order using exchange sort { int i, j, ans; string ans2; int temp; // temporary holding variable int numLength = 10; for(int i=0; i<10; i++) { for(int j=0; j<10; j++) { if(markArray[j] avg){ //check what values are greater than average value cout << nameArray[j] << " " << markArray[j] << endl; } } } void displaynames(){ //to display the names, marks and the grading string seek; int i,x; cout<< "Enter a student's name"<> seek; for (i=0;i<10;i++){ if (nameArray[i]==seek){ if (markArray[i]>=75 && markArray[i]<=100){ cout << nameArray[i]<< " "<=65 && markArray[i]<=74){ cout << nameArray[i]<< " "<=40 && markArray[i]<=64){ cout<< nameArray[i]<< " "<>markArray[0]; cout<<"Enter Name: "; cin >> nameArray[0]; cout <<"Student 02"<>markArray[1]; cout<<"Enter Name: "; cin >> nameArray[1]; cout <<"Student 03"<>markArray[2]; cout<<"Enter Name: "; cin >> nameArray[2]; cout <<"Student 04"<>markArray[3]; cout<<"Enter Name: "; cin >> nameArray[3]; cout <<"Student 05"<>markArray[4]; cout<<"Enter Name: "; cin >> nameArray[4]; cout <<"Student 06"<>markArray[5]; cout<<"Enter Name: "; cin >> nameArray[5]; cout <<"Student 07"<>markArray[6]; cout<<"Enter Name: "; cin >> nameArray[6]; cout <<"Student 08"<>markArray[7]; cout<<"Enter Name: "; cin >> nameArray[7]; cout <<"Student 09"<>markArray[8]; cout<<"Enter Name: "; cin >> nameArray[8]; cout <<"Student 10"<>markArray[9]; cout<<"Enter Name: "; cin >> nameArray[9]; bool flag = true; while(flag){ int option; // storing the option user selected float avg; cout << "What do you want to do? Please enter a number to choose from the below"<> option; switch(option){ case 1: ExchangeSort(); break; case 2: avg = calculateAverage(); break; case 3: calculateAboveAverage(); break; case 4: displaynames(); break; default:flag = false; cout<< "Enter a number from 1 to 4"<
I don't understand what you mean by 'sequence' but I can help you with the last two.

selection: the code starting at line 182 and ending at 203 and any other if...else in your code. It's a "selection" because it selects from several cases (if(condition) <code> else <some_other_code>; and switch being just multiple if...else's)

iteration: to iterate means to go through every element of a structure and either look at it or do some operation on it. The code inside ExchangeSort(), calculateAverage(), calculateAboveAverage() and displaynames() does this.
@goth, thanks alot for the great help!
selection and iteration are clear enough for me. i simply didnt undrstand wat sequence was either. it was only mentioned in the question. dat doesnt matter.
Thank you very much for your help and time!!!! :)
Sequence is the most basic of all. It is simply a group of instructions which are executed in a linear fashion, one after another. The flow of control simply steps through the code one line at a time.
Last edited on
Topic archived. No new replies allowed.