Rate my code /g/ :^)
>>59043085
it's shit
>>59043113
Why?
>>59043085
>bottles and i are separate variables
Once you've fixed that, now make it start at a given value (instead of 99).
>>59043085
I don't understand what your program does, what are you trying to achieve here?
That's not how the song goes
kinda goofy
>>59043227
How's this?
>>59043254
By looking at whatever he's printing out, it's just the "99 Bottles of Beer" song.
Also yeah OP, >>59043380 is right, who the hell "shuffles around" bottles of beer?
IT "PASS IT AROUND"YOU FUCKING MEMER
>>59043085if() {
}
//not
if()
{
}
cia nigger
>>59043428
>>59043430
I was just trying to add a little personal spice to my script
>>59043085
>using namespace std;
>std::cout
good one.
>>59043421
>i=i
Just leave that part empty.for(; i > 0; --i)
>>59043455
Why?
>>59043085
wont start each verse on an odd number? so you're skipping the even verses.
>>59043085
pajeet/10
>>59043421
Also, you don't need that s variable, just use a ternary operator.(i == 1 ? "" : "s")
what the fuck is this autistic poem?
>>59043478
you are saying "I'm using the namespace std" so you don't have to write std::blah_di_blah, but you are writing it anyway. You just need cout with no std::
Also, that's fairly bad practice, to use a blanket "using namespace ...." statement, it defeats the entire purpose of having namespaces. If you want to know why, just ask.
>>59043453
If the spice was homosexuality, ya fucking nailed it faggot.
Don't fuck with road trip songs, that's how you die.
>>59043516
Sorry, I learned from learncpp.com :^)
>>59043085
>using namespace std;
>std::cout
>std::
>bottles -= 1;
>not just using bottles--;
>using strings for single char
>using string library at all
>having separate ints for bottles and counting even though they are the same value
>wasting three lines on curly brackets even though conditions contain a single statement
>using iostream library when simply printf would suffice
>>59043542
>not learncp.com
>>59043549
This is how bloatware is made, right?
>>59043469
What's the difference between --i and i--?
>no space on both sides of "<<"s
D R O P P E D
>>59043542
no worries, we all start somewhere. just keep working. You know how to compile successfully, yes?
>>59043585
Prefix and postfix
It makes no difference in a for loop but necessary if your using it in conditionals or functions. A prefix subtracts before checking and a postfix checks and then subtracts. Consider it an order of operations
>>59043585
i--; // take the value of i then decrement
--i; // decrement i then take the value
>>59043604
I guess? I started by using codeblocks in Windows (shut up, I know, visual studio is too big of a download), but for this little loop I was just using nano and g++ via a Linux terminal because I thought it'd be fun.
>>59043662
I hope the markdown works.
I'm drunk, but I modified the code a bit, it probably sucks.
```c++
#include <iostream>
#include <string>
using std::cout;
using std::string;
int main() {
string bottles = " bottles";
for (int i = 99; i > 0; i--) {
cout << i << bottles << " of beer on the wall, "
<< i << bottles << " of beer.\n";
if (i - 1 == 1)
bottles = " bottle";
else if ( i - 1 == 0)
bottles = " no more bottles";
cout << "You take one down, pass it around,"
<< i << bottles << " of beer on the wall.\n";
}
cout << std::endl; // May as well flush the stream.
return 0;
}
```
>>59043085
why do people even use cout?
it's so ugly and messy
is there something wrong with printf?
>>59043882
Python fag detected
>>59043085
>old shit langs
>>59043882
cout << bottles << "bottles of beer on the wall, " << bottles << "bottles" << " of beer on the wall"<<endl;
vs
printf("%d bottles of beer on the wall, %d bottles of beer on the wall\n" bottles);
>>59043975
it's C faggot
>>59043984
You are literally retarded. Kill yourself, you dumb fucking shit stain.
>>59044015
no u
>>59044019
You deserve to be buried alive in a box full of spiders, you fucking subhuman sack of shit. Your mother should be stoned to death for not having you aborted, you worthless shit stain.
>>59044019
Get raped and kill yourself you retarded fucking faggot sack of nigger shit with down syndrome.
>>59043815
code tags bro (bb style)
>>59043984
Both are shit. cout for overloading the bitwise shift and causing a large trend to change that operator into a stream operator, and printf for having to parse format strings.
God I hate how I work in c and c++ every day
>>59043085
The one and only way to do bottles of beer.
(I am not serious)
>shuffle it around
THAT'S NOT HOW IT GOES RREEEEEEE
senior cs/10
>>59043085
wtf, one of the worst code samples I've seen... why not s = (bottles == 1) ? "" : "s"
>>59043085
Made an attempt as well ^^
>>59043085
Weird code style.
>>59043542
learncpp.com tells you to not use the namespace for no reason...
>>59043085
>using std:: when he declared namespace std
>>59043085
poop/shit
>>59043085
>>59043542
>using the smiley with a carat nose
>>59043085
>>59043421
Thanks for making me want to kill myself