Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
I have the answer to this equation in Pascal. Can anyone help me convert this to c or c ++?
equation: y1+y2+y3+y4=12 yi ≥ 0 , 0 ≤ i ≤ 4

pascal code (but i cant run it) :
program selections3 (input,output);
x1,x2,x3: integer;
for x1 :=0 to 12 do
for x2 :=0 to 12 - x1 do
for x3 :=0 to 12 - x1 - x2 do

What I have tried:

i tride debuging it but i cant
Updated 28-Apr-21 9:54am
Jerry Jeremiah 4-May-21 1:47am    
You can compile and run the pascal version like this:
The C++ version is:

1 solution

This is not a code conversion service but I will give you a hint. The Pascal for loop of this form :
for x1 :=0 to 12 do
looks like this in c++ :
for( x1 = 0; x1 <= 12; ++x1 )
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900