1. ## Nested Loops

I am in dire need of figuring out how to run this program using nested loops. It's a Van der Waal equation assignment, but I need to use nested loops for incremental increases. Here's what I have so far.

Code:
```#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

// Define constants.

#define a 3.952
#define b 0.0427
#define R 0.08206
#define mL_L .001

int main ()
{
float moles;            //IN: Number of moles of CO2 (n).
float temp;                //IN: Temperature (K).
float initial;            //IN: Initial volume (mL).
float final;            //IN: Final volume (mL).
float increment;        //IN: Increment volume (mL) b/w lines of the table.
float pressure;            //OUT: Pressure (atm).
float loopVol;            //Variable assignment for loop function.
float volume;            //Variable assignment for calculations.

//Request user input.

cout << "\nEnter the quantity of Carbon Dioxide (moles): ";
cin >> moles;
cout << "\nEnter the Temperature (K): ";
cin >> temp;
cout << "\nEnter the Initial Volume (mL): ";
cin >> initial;
cout << "\nEnter the Final Volume (mL): ";
cin >> final;
cout << "\nEnter the Volume Increment (mL): ";
cin >> increment;

//Set for table.

cout << "\n\nVolume (mL)                    Pressure (atm)" << endl;

//Begin calculations.

for(loopVol = initial; loopVol <= final; loopVol += increment)
{
printf("  %.2f", loopVol);
volume = loopVol * mL_L;
pressure = (moles * R * temp)/(volume - b * moles) - (a * moles * moles)/(volume * volume);

printf("                             %.4f",pressure);
} while (loopVol <= final);

return 0;
}```

2. Yes, I posted that, too. But, as you'd notice, they weren't able to help :/.

3. There is no nested loop in that code. There are two separate loops, a for loop and a while loop. They are not nested.

This is a rewrite of lines 43-50 of your code, with indenting and comments changed to reflect what the code DOES.

Code:
```for(loopVol = initial; loopVol <= final; loopVol += increment)
{
printf("  %.2f", loopVol);
volume = loopVol * mL_L;
pressure = (moles * R * temp)/(volume - b * moles) - (a * moles * moles)/(volume * volume);

printf("                             %.4f",pressure);
}    // for loop ends here

// and a new while loop here
while (loopVol <= final);```
The while loop will do nothing, since loopVal will be equal to final+1 after completion of the preceding for loop.

Nobody can help you more than that. Van der Waal's equation does not involve loops, and you have been very unclear on what you're trying to achieve, let alone why you think nested loops will achieve it.

If you believe there is a nested loop in your code, you're in trouble. You need to go back to your textbook, and read the section on loops, in order to understand what a nested loop actually is.