What is wrong with the code bro? Can you do better?
John Myers
What did you expect from this place
Matthew Thompson
I remember my first day in intro to programming too :)
Jacob Collins
15 will print FizzBuzz, Fizz, and Buzz. You failed FizzBuzz.
Michael Peterson
Good job, you wrote a bunch of gibberish. Are you proud of yourself ?
Liam Williams
pause: not found
Matthew Walker
you have a syntax error.
Samuel Rodriguez
string a="op";
switch(a) { case "op": printf("neck") break; default: printf(a + "is a faggot"); break; }
Joseph Morales
It's not in a code box
Owen Moore
import sys for op in range(1, 101): op_is_a_faggot = op % 3 == 0 op_sucks_ladycock = op % 5 == 0 op_takes_it_up_the_ass = not op % 3 == 0 and not op % 5 == 0 if op_is_a_faggot: sys.stdout.write('Fizz') if op_sucks_ladycock: sys.stdout.write('Buzz') if op_takes_it_up_the_ass: sys.stdout.write(str(op)) sys.stdout.write('\n') sys.stdout.flush()
I forgot to put "else if" for the conditional statements following the first if. I also forgot to put \n after Fizz Buzz, Fizz, and Buzz. Also I forgot to close the curly bracket in the loop.
I am self taught bro. Do you think I have a chance to work at goggle?
Any common multiple of 3 and 5 will output Fizz Buzz, Fizz and Buzz. You don't need three conditionals. Just one for modulo 3, one for modulo 5 and modified handling of print statements.
Also, is this not bait?
Brayden Wright
>system("pause") i bet it took you more time to load up your IDE than it took for you to write that joke of a program
Chase Ward
See
Liam Thomas
What is wrong with pausing the system please?
Adrian Baker
I fixed my app guys it should work now! #include
int main (){
int i;
for (i = 0; i < 101; i++){ if ((i % 3 == 0) && (i % 5 == 0) && (i !=0)){ printf ("Fizz Buzz\n"); } else if ((i % 3 == 0) && (i !=0)){ printf ("Fizz\n"); } else if ((i % 5 == 0) && (i !=0)){ printf ("Buzz\n"); } else { printf ("%d\n", i); } }
system ("pause"); return 0;
}
Jacob Torres
you still don't need three conditionals; two would suffice.
Jeremiah Stewart
It ("pause" parameter) is platform specific; It's also not in stdio.h.
Same line bracing can actually get you fired in some places I've seen
Julian Jones
I would need to make an array with a varying set of elements but then I'd still end up with a bunch of condotional statements to control what's in the array for a given instance.
Nathaniel Myers
Why is he looking at backwards text on his monitor?
Brandon Campbell
Syntax error on line 4.
Michael Stewart
you're hired
Matthew Lee
Faag
Xavier Hill
No you wouldn't Look at . Start from one. Simply move the newline character to after all conditionals have evaluated. Then evaluate modulo 3 (if == 0, output 'fizz'), modulo 5 (if == 0, output 'buzz'), else output the number. Then newline.
For a common multiple of 3 and 5 like 15, this would output 'fizz' (after modulo 3 evaluation) and 'buzz' (after modulo 5 evaluation) for 'fizz buzz' in total.
Jose Wright
static const char *out[] = { "", "", "fizz", "", "buzz", "fizz", "", "", "fizz", "buzz", "", "fizz", "", "buzz", "fizzbuzz", }; for (int i = 1; i
Was that written in C#? Similar methodology doesn't work in C. You can't apply the += operator to append a character array. I used strcat to add Fizz if i % 3 returns no remainder like you did there and set it to append (that is strcat" the string with "fizz". Same thing for buzz. Else, I simply overwrite the string with whatever is the value of i. However, it comes completely fucked up. Numbers output fine but for the terms that should come out as fizz, buzz, or fizzbuzz, they come out fucked up like "4buzzfizz"
actually I caught that, but generally the ints that are divisible by both are accepted to just be the first, from every explanation I've seen. Here's what I did to change it. I could have also just removed the else I suppose #include using namespace std;
You're right. My apologies. If it really is your first, congratulations, as there are apparently many "programmers" who can't do this. There are multiple valid ways to solve the problem, and it's interesting to compare them.The one below cuts down on the number of evaluations needed, performing at most 3 per digit. #include
int main(void) {
for (int i = 1; i < 101; i++){ if (!(i % 3)){ printf ("Fizz"); } if (!(i % 5)){ printf ("Buzz"); } else if ((i % 3)) { printf("%d", i); } printf("\n"); } return 0; }