Thread: How can i convert c++ to c (help!!!)

1. How can i convert c++ to c (help!!!)

hello everyone, how can i convert this code from C++ to C language. This is quite important to me. Please help me. thanks...

Code:
```#include <iostream>
#include <vector>

static const int UPPER_BOUND = 100;

int main() {
std::vector<int> landings;
// Push in doubles.
for (int i = 1; i <= 20; ++i) {
landings.push_back(2 * i);
}
landings.push_back(2 * 25);
// Push in singles.
for (int i = 1; i <= 20; ++i) {
landings.push_back(i);
}
landings.push_back(25);
// Push in trebles.
for (int i = 1; i <= 20; ++i) {
landings.push_back(3 * i);
}

int nCheckOuts = 0;
for (int i = 0; i < 21; ++i) {
int sum = landings[i];
if (sum < UPPER_BOUND) {
++nCheckOuts;
}
for (int j = 0; j < 62; ++j) {
sum += landings[j];
if (sum < UPPER_BOUND) {
++nCheckOuts;
}
for (int k = j; k < 62; ++k) {
sum += landings[k];
if (sum < UPPER_BOUND) {
++nCheckOuts;
}
sum -= landings[k];
}
sum -= landings[j];
}
}
std::cout << nCheckOuts << std::endl;

return 0;
}```

2. Where's your attempt at converting this C++ code to C? That code is almost C...

A vector is like an array. Make an array of size 62 and convert push_back accordingly
cout to printf
etc...

3. As Zeus_ said it's basically C anyway.

My reason for not answering you is that I don't think that plagiarism is good. I doubt your teachers think it's a good thing either. If I can find where you stole your source code from on my first attempt I'm pretty sure your teachers can as well. But, maybe you don't care.

Anyway, moving on, it took me 30 seconds (literally) to convert that to C using Zeus_'s suggestions. I'm not going to paste the code here because it's not your code. I only bothered even looking at it more closely because the solution seemed different to my own solution of the same Project Euler problem.

Is your course related to programming or mathematics?