Pascal

Copy Code

for x1 :=0 to 12 dolooks like this in c++ :

C++

Copy Code

for( x1 = 0; x1 <= 12; ++x1 ) { }

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);

var

x1,x2,x3: integer;

begin

for x1 :=0 to 12 do

for x2 :=0 to 12 - x1 do

for x3 :=0 to 12 - x1 - x2 do

writlen('x1=',x1-2:0,'x2='x2-2:0,'x3='x3-2:0,'x4=',12-x1-x2-x3-2:0)

end.

**What I have tried:**

i tride debuging it but i cant

equation: y1+y2+y3+y4=12 yi ≥ 0 , 0 ≤ i ≤ 4

pascal code (but i cant run it) :

program selections3 (input,output);

var

x1,x2,x3: integer;

begin

for x1 :=0 to 12 do

for x2 :=0 to 12 - x1 do

for x3 :=0 to 12 - x1 - x2 do

writlen('x1=',x1-2:0,'x2='x2-2:0,'x3='x3-2:0,'x4=',12-x1-x2-x3-2:0)

end.

i tride debuging it but i cant

Comments

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

The C++ version is: https://onlinegdb.com/HJoukD0D_