File tree 2 files changed +66
-0
lines changed
2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* *
2
+ * @author dsdsharma
3
+ * @date 20/12/2018
4
+ */
5
+
6
+ #include < iostream>
7
+
8
+ using namespace std ;
9
+
10
+ int main ()
11
+ {
12
+ int n;
13
+ cout << " ====Fizz Buzz ====" << endl;
14
+ cout << " Enter the number: " ;
15
+ cin >> n;
16
+ for (int i=1 ; i<=n; i++){
17
+ if (i%5 ==0 && i%3 ==0 ){
18
+ cout << " FizzBuzz " ;
19
+ }else if (i%3 ==0 ){
20
+ cout << " Fizz " ;
21
+ }else if (i%5 ==0 ){
22
+ cout << " Buzz " ;
23
+ }else {
24
+ cout << i << " " ;
25
+ }
26
+
27
+ }
28
+
29
+ return 0 ;
30
+ }
Original file line number Diff line number Diff line change @@ -172,3 +172,39 @@ for i in range(1, n):
172
172
print(i)
173
173
```
174
174
175
+ ## C++ Implementation
176
+
177
+ ### [FizzBuzz.cpp](./C++/FizzBuzz.cpp)
178
+
179
+ ```c
180
+ '''
181
+ * @author: Deepak Sharma
182
+ * @github: https://github.com/dsdsharma
183
+ * @date: 20/12/2018
184
+ '''
185
+ #include <iostream>
186
+
187
+ using namespace std;
188
+
189
+ int main()
190
+ {
191
+ int n;
192
+ cout << "====Fizz Buzz ====" << endl;
193
+ cout << "Enter the number: ";
194
+ cin >> n;
195
+ for(int i=1; i<=n; i++){
196
+ if(i%5==0 && i%3==0){
197
+ cout << "FizzBuzz ";
198
+ }else if(i%3==0){
199
+ cout << "Fizz ";
200
+ }else if(i%5==0){
201
+ cout << "Buzz ";
202
+ }else{
203
+ cout << i << " ";
204
+ }
205
+
206
+ }
207
+
208
+ return 0;
209
+ }
210
+ ```
You can’t perform that action at this time.
0 commit comments