[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 17
Thread images: 1
File: 3long5MePlsShowHowMakeClean.png (15 KB, 442x623) Image search: [Google]
3long5MePlsShowHowMakeClean.png
15 KB, 442x623
New to programming.
Is there an easier way to do this?
tips/suggestions?
>>
>>53647567
Learn how the language works and what constructs it offers first.

There are 3 VERY BASIC things which you can use here to make your life a lot easier, which you'll have to figure out.
>>
learn the basics and use fucking for-loops
>>
>>53647567
>>53647653
Also, there's already a thread for this shit called daily programming thread.

Lurk moar.
>>
also quit using arrays
>>
There's no mod in C?
>>
and i thought my code is horrible
>>
>>53647567
#include <iostream>

using namespace std;

int main(void)
{
int i;
cout << "Even numbers to twenty are ";
for (i = 0; i <= 20; i++)
if (i % 2 == 0)
cout << i << " ";
cout << endl;

cout << "Odd numbers to twenty are ";
for (i = 0; i <= 20; i++)
if (i % 2 == 1)
cout << i << " ";
cout << endl;
return 0;
}
[\code]
>>
>>53647567
Haven't used c++ in some time, but you probably want to do something like this
#include <iostream>
#include <vector>

using namespace std;

int main()
{
vector<int> evens;
vector<int> odds;

for (int i = 0; i <= 20; i++)
{
if (i % 2 == 0)
{
evens.push_back(i);
}
else
{
odds.push_back(i);
}
}

cout << "Evens:" << endl;
for (int n : evens)
{
cout << n << " ";
}
cout << endl;

cout << "Odds:" << endl;
for (int n : odds)
{
cout << n << " ";
}

return 0;
}
>>
>>53647567
functions
>>
yea you should be using python
from faggot import OP

print range(0,20,2)
print range(1,20,2)
>>
>>53647567
When I see shit like this I know my job is pretty safe for at least another generation...
>>
>>53649828
Pretty much the same in racket:
(display (range 0 20 2))
(display (range 1 20 2))

Or:
(display (filter even? (range 20)))
(display (filter odd? (range 20)))
>>
>he fell for the C as a first language meme
You poor bastard
>>
>>53650903
that's cpp
>>
>>53650903
It’s C++, but I agree with you.
Though if they succeed learning and mastering this language, this could be a pretty huge advantage for them later
>>
Not OP. I am starting a new job on the 4th of next month programming in BCPL... The interviewers joked about it calling it 'Before C Programming Language', invented in 1966.

Should be fun I guess and I can't find much about it at all. I feel like continuing with C/C++ will be a good step for me now, moving from a primarily PHP background.
Thread replies: 17
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.