Quick For loop question

Hi, this will just be a few seconds. What do I put in the parameter of the for loop?

Specifically this:

For inputC <- 0 to 1 Do
For inputA <- 0 to 1 Do
For inputB <- 0 to 1 Do
Instantiate a FullAdder object named adder passing inputA, input B, and inputC to the ctor.
Send " " followed by inputC followed by " " followed by inputA followed by " " followed by
inputB followwed by " | " to cout.
Send adder.GetOuputC() followed by " " followed by adder.GetOutputS() followowed by endl to cout.
End For
End For
End For
1
2
3
4
5
6
7
8
9
10
for(inputC = 0; inputC <= 1;inputC++)
{
      for(do for input A)
      {
           for(do for inputB)
           {
                 std::cout << " " << "do the rest by yourself" << std::endl;
           }
     }
}

^^^ thank you!

Here's what I got:

1
2
3
4
5
6
7
8
9
10
11
12
13
for (int inputC = 0; ;)
    {
        for (int inputA; ;)
        {
            for (int inputB ; ;)
            {
                FullAdder adder;
                adder.FullAdder::FullAdder(inputA, inputB, inputC);
                cout << "   " << inputC << "  " << inputA << "  " << inputB << " |     ";
                cout << adder.GetOutputC() << "  " << adder.GetOutputS() << endl;
            }
        }
    }
Last edited on
- You have to increment the counter in for loops.
- Add the for loop end condition. See how I have done it.

Rest looks fine.
Topic archived. No new replies allowed.