CMPC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

FizzBuzz Program

3 posters

CMPC :: Computing :: Programming :: C++

Go down

FizzBuzz Program Empty FizzBuzz Program

Post by Admin Wed Dec 02, 2009 12:50 am



Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by Paul Wed Dec 02, 2009 3:10 am

FizzBuzz is lame, stupid, retarded . . . etc.

Code:

#include <iostream>
using namespace std;

int main()
{
    for(int i = 0; i <= 100; i++)
    {
        if(i%3)cout << "Fizz";
        if(i%5)cout << "Buzz";
        if(!(i%3 || i%5))cout << i;
        cout << endl;
    }
    return 0;
}
Paul
Paul
Pickaxe

Posts : 611

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by Admin Wed Dec 02, 2009 11:46 pm

NO U!
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by zodiacescuchion Thu Dec 03, 2009 1:28 am

Can you tell me all of the math symbols useable in cpp. i didnt know there was a factor symbol
zodiacescuchion
zodiacescuchion
Skid

Posts : 28

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by Admin Thu Dec 03, 2009 1:39 am

there is no such thing as a factor symbol


oh huh i didn't teach you that yet.


well here's the lesson.


whenever there is an exclamation mark in front of anything (other than in a string, in which case it's just a punctuation mark) , it means "not"


so if it is in front of an equal sign it means "does not equal". the exclamation mark is used for such a thing because .... well... do you see a "not equal" sign on your keyboard? NO! lol so we have to make a combination of keys equivalent to the not equal sign.


also all math symbols are +, -, /, *, %

that's it.


the percent sign is called the modulus operator. it divides the two numbers and spits out the remainder of the division

for instance 12%10 would spit out 2.

16%3 would spit out 1

11%5 would spit out 1. etc etc etc.



math FUNCTIONS are a different story. check the C++ math library for that. link to math library
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by zodiacescuchion Thu Dec 03, 2009 1:49 am

Oh okay i already understood the factorial sign meant not. but the % sign was confusing me. I know that parantheses are used to get a bool value so im guessing that when you use the % sign in parantheses it has the remainder has to equal zero
zodiacescuchion
zodiacescuchion
Skid

Posts : 28

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by zodiacescuchion Thu Dec 03, 2009 1:55 am

I tried that fizz buzz program in the second post and it ended up doing the opposite
zodiacescuchion
zodiacescuchion
Skid

Posts : 28

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by Admin Thu Dec 03, 2009 2:05 am

well that's because pual wrote it incorrectly. idiot forgot something important. try it yourself then ask for the solution if you REALLY are stuck Razz
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by Paul Sat Dec 05, 2009 12:49 am

Ah shuddup, You've made stupider mistakes and besides I was tired.
Paul
Paul
Pickaxe

Posts : 611

Back to top Go down

FizzBuzz Program Empty Re: FizzBuzz Program

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

CMPC :: Computing :: Programming :: C++

 
Permissions in this forum:
You cannot reply to topics in this forum