Home c++ Translating code from Pascal to C++

# Translating code from Pascal to C++

Author

Date

Category

Help translate the C++ code

``````var d1, d2, d3, k, n: integer;
begin
writeln ('Enter the number n with which we will compare the sum of the digits of the number');
k: = 0;
{d1 - left, d2 - middle, d3 - right digits of the number}
for d1: = 1 to 9 do
for d2: = 0 to 9 do
for d3: = 0 to 9 do
if (d1 + d2 + d3 = n) then
begin
k: = k + 1;
write (d1, d2, d3, '');
end;
writeln ('The number of required numbers is -', k);
end.
``````

``````# include & lt; stdio.h & gt;
int main (int argc, char * argv []) {
int d1, d2, d3, k, n;
printf ("Enter the number n with which we will compare the sum of the digits of the number \ n");
scanf ("% d", & amp; n);
k = 0;
for (d1 = 1; d1 & lt; = 9; ++ d1)
...
...
if (d1 + d2 + d3 == n) {
k + = 1;
printf ("% d% d% d", d1, d2, d3)
}
...
}
``````

What to insert instead of ellipsis, I think you’ll figure it out.

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.