FizzBuzz Program
3 posters
CMPC :: Computing :: Programming :: C++
Page 1 of 1
FizzBuzz Program
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- Pirate King
- Posts : 559
Re: FizzBuzz Program
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- Pickaxe
- Posts : 611
Re: FizzBuzz Program
Can you tell me all of the math symbols useable in cpp. i didnt know there was a factor symbol
zodiacescuchion- Skid
- Posts : 28
Re: FizzBuzz Program
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
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- Pirate King
- Posts : 559
Re: FizzBuzz Program
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- Skid
- Posts : 28
Re: FizzBuzz Program
I tried that fizz buzz program in the second post and it ended up doing the opposite
zodiacescuchion- Skid
- Posts : 28
Re: FizzBuzz Program
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
Admin- Pirate King
- Posts : 559
Re: FizzBuzz Program
Ah shuddup, You've made stupider mistakes and besides I was tired.
Paul- Pickaxe
- Posts : 611
CMPC :: Computing :: Programming :: C++
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|