FizzBuzz Program

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

Go down

FizzBuzz Program

Post by Admin on 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”.
avatar
Admin
Pirate King

Posts : 559

Back to top Go down

Re: FizzBuzz Program

Post by Paul on 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;
}
avatar
Paul
Pickaxe

Posts : 611

Back to top Go down

Re: FizzBuzz Program

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

NO U!
avatar
Admin
Pirate King

Posts : 559

Back to top Go down

Re: FizzBuzz Program

Post by zodiacescuchion on 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
avatar
zodiacescuchion
Skid

Posts : 28

Back to top Go down

Re: FizzBuzz Program

Post by Admin on 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
avatar
Admin
Pirate King

Posts : 559

Back to top Go down

Re: FizzBuzz Program

Post by zodiacescuchion on 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
avatar
zodiacescuchion
Skid

Posts : 28

Back to top Go down

Re: FizzBuzz Program

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

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

Posts : 28

Back to top Go down

Re: FizzBuzz Program

Post by Admin on 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
avatar
Admin
Pirate King

Posts : 559

Back to top Go down

Re: FizzBuzz Program

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

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

Posts : 611

Back to top Go down

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