Answer:
for(i = 0 ; i < NUM_VALS; ++i)
{
cout << courseGrades[i] << " ";
}
cout << endl;
for(i = NUM_VALS-1 ; i >=0 ; --i)
{
cout << courseGrades[i] << " ";
}
cout << endl;
Explanation:
The first loop initializes i with 0, because we have to print the elements in order in which the appear in the array. We print each element, adding a space (" ") character at its end. After the loop ends, we add a new line using endl.
The second loop will print the values in a reverse order, so we initialize it from NUM_VALS-1, (since NUM_VALS = 4, and array indices are 0,1,2,3). We execute the loop till i >= 0, and we print the space character and new line in a similar way we executed in loop1.
Answer:
Explanation:
#include <iostream>
using namespace std;
// Recipe of single portion salad
int main()
{
float Qing[3]={0.0,0.0,0.0};
string ItemName[3]={" "," "," "};
int qty=0;
cout<<"Please enter 3 Ingredients required for Salad and Quantity required for a single serve"<<endl;
for (int i=0;i<3;i++)
{
cout<<"Enter the ingredient number "<<(i+1)<<" :";
cin>>ItemName[i];
cout<<"Qty required for single serve (in Oz) :";
cin>>Qing[i];
}
cout<<"Number of servings required :";
cin>>qty;
cout<<endl<<"Total Quantities required for "<<qty<<" servings"<<endl;
for (int i=0;i<3;i++)
{
cout<<ItemName[i]<<" Qty for "<<qty<<" servings :"<<(Qing[i]*qty)<<" Oz."<<endl;
}
return 0;
}
// You can run this after compiling without any problem.
restart.is done after the computer is passed through configuration
Automatic, three speed transmission