I am new to c++ and i advice for this particular assignment. I new to programming.

The instruction is to use while loop for the two output process and for loop for the other 2 output.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    system("color 4");

    int firstNum, secondNum, num;
    int sumE = 0, sumO = 0, sum_square = 0, firstNumA, secondNumB;
    int a,z;

    int counter = 10;



    cout << "Enter first number: \a";
    cin >> firstNum;
    cout << "Enter second number: \a";
    cin >> secondNum;

    firstNumA = firstNum;
    secondNumB = secondNum;
    {
    if (firstNum >= secondNum)
    cout << "Wrong value \n" << endl;

    else if (firstNum <= secondNum)

     cout << "\n\n\nThe odd numbers are: " << endl;

   while (firstNum <= secondNum)
   {
         if ((firstNum%2) != 0)
         {


         cout << firstNum;
         sumO += firstNum;
}
 firstNum++;

 if (((firstNum % 2) != 0) && (firstNum != secondNum))
{

}
} 
cout << "\n\n\nThe total odd number is: " << sumO  << endl;

cout << "\n\n\nThe even numbers are: " << endl;
     while (firstNumA != secondNumB)
{
      if ((firstNumA % 2) == 0)
{
      cout << firstNumA;
       sumE += firstNumA; 
}

firstNumA++;

      if (((firstNumA%2) == 0) && (firstNumA != secondNumB))
      {

      }
      }
      cout << "\n\n\nSum of even numbers is: " << sumE << endl;
      }


      a = firstNum;
      z = secondNum;



      cout << firstNum;
      sum_square += firstNum*firstNum;


      while (a <= z)
      {

      cout <<"\n"<< firstNum <<"\t"<< firstNum * firstNum;
        firstNum++;



        }
    cout << "\n\n\nThe sum square is: " << sum_square << "\n\n\n";



while (counter >=0)
{
      cout << setw(counter+10) << counter << endl;
      counter--;
      }
       system ("pause");
    return 0;

}

could you explain your problem.
also note that in c++ use should use cmath instead of math.h.
And forget about system(...) command. They are BAD.

could you explain your problem.
also note that in c++ use should use cmath instead of math.h.
And forget about system(...) command. They are BAD.

Thank you.
I only have less than a month programming experience.
As for now, the program compiles but I need to use a while loop for the two output and for loop for the other 2 output and I don't know where to start.

I am new to c++ and i advice for this particular assignment. I new to programming.

The instruction is to use while loop for the two output process and for loop for the other 2 output.

Start with code tags and good formatting, as mentioned in your other thread.

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    system("color 4");

    int firstNum, secondNum, num;
    int sumE = 0, sumO = 0, sum_square = 0, firstNumA, secondNumB;
    int a,z;

    int counter = 10;



    cout << "Enter first number: \a";
    cin >> firstNum;
    cout << "Enter second number: \a";
    cin >> secondNum;

    firstNumA = firstNum;
    secondNumB = secondNum;
    {
    if (firstNum >= secondNum)
    cout << "Wrong value \n" << endl;

    else if (firstNum <= secondNum)

     cout << "\n\n\nThe odd numbers are: " << endl;

   while (firstNum <= secondNum)
   {
         if ((firstNum%2) != 0)
         {


         cout << firstNum;
         sumO += firstNum;
}
 firstNum++;

 if (((firstNum % 2) != 0) && (firstNum != secondNum))
{

}
} 
cout << "\n\n\nThe total odd number is: " << sumO  << endl;

cout << "\n\n\nThe even numbers are: " << endl;
     while (firstNumA != secondNumB)
{
      if ((firstNumA % 2) == 0)
{
      cout << firstNumA;
       sumE += firstNumA; 
}

firstNumA++;

      if (((firstNumA%2) == 0) && (firstNumA != secondNumB))
      {

      }
      }
      cout << "\n\n\nSum of even numbers is: " << sumE << endl;
      }


      a = firstNum;
      z = secondNum;



      cout << firstNum;
      sum_square += firstNum*firstNum;


      while (a <= z)
      {

      cout <<"\n"<< firstNum <<"\t"<< firstNum * firstNum;
        firstNum++;



        }
    cout << "\n\n\nThe sum square is: " << sum_square << "\n\n\n";



while (counter >=0)
{
      cout << setw(counter+10) << counter << endl;
      counter--;
      }
       system ("pause");
    return 0;

}

It's unreadable the way it is and hence not debuggable.

I need to use a while loop for the two output and for loop for the other 2 output and I don't know where to start.

That's part of the "how". What's the "what"? What is the goal of the program. What is the program supposed to do? Please explain in a short paragraph, but format the code first and repost in code tags. See Walt P's link in the other thread.

The instruction is to use while loop for the two output and use for loop for the other two output. The program compile and runs, but I don't know where to put the for loop without messing up the program.

The instruction is to use while loop for the two output and use for loop for the other two output. The program compile and runs, but I don't know where to put the for loop without messing up the program.

Again, that's the "how". The "what" would be something like "Read in two numbers from the user. Display all the odd numbers in between those two numbers. Then display all the even numbers between those two numbers. Then display the sum of all the numbers in between those two numbers. then display the sum of all the squared values of the numbers in between those two numbers..."

Presumably there is some assignment specification with the goal of the program and hints/restrictions on how to accomplish it. Within those hints/restrictions would be the idea of four loops, two o them while-loops, two of them for-loops.

Format your code. All loops have nested blocks of code. You need to be able to identify them. You can't do that without consistent indentation and bracketing practices. This is important always, but even MORE important when you are just starting out.

Lines 44 - 47 - This if-statement has no execution block. Delete it or add one.

Line 25 - Why is that bracket there?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.