Skip to content

Commit 95a59ab

Browse files
solves conditional statements
1 parent f619e91 commit 95a59ab

6 files changed

+96
-16
lines changed

README.md

+4-14
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88
This repository contains solutions to the [C++ domain](https://www.hackerrank.com/domains/cpp)
99
part of HackerRank. My HackerRank profile can be viewed [here](https://www.hackerrank.com/anishviewer).
1010

11-
Solutions to other domains on HackerRank that can be viewed at:
12-
13-
| Domain | Solutions Repository Link |
14-
|--------|---------------------------|
15-
| [Python](https://www.hackerrank.com/domains/python) | [Solutions Repository](https://github.com/anishLearnsToCode/hackerrank-python) |
16-
| [Algorithms](https://www.hackerrank.com/domains/algorithms) | [Solutions Repository](https://github.com/anishLearnsToCode/hackerrank-algorithms) |
17-
| [Data Structures](https://www.hackerrank.com/domains/data-structures) | [Solutions Repository](https://github.com/anishLearnsToCode/hackerrank-data-structures) |
18-
| [Java](https://www.hackerrank.com/domains/java) | [Solutions Repository](https://github.com/anishLearnsToCode/hackerrank-java) |
19-
| [Interview Preparation Kit](https://www.hackerrank.com/interview) | [Solutions Repository](https://github.com/anishLearnsToCode/hackerrank-interview-preparation-kit) |
20-
2111
The C++ Domain is further Divided into the following sub-domains.
2212

2313
## Sub Domains & Problems (+Solutions) in the C++ Domain
@@ -26,10 +16,10 @@ The C++ Domain is further Divided into the following sub-domains.
2616

2717
| Problem | Difficulty | Solution |
2818
|---------|:----------:|:--------:|
29-
| [Say "Hello World" with C++](https://www.hackerrank.com/challenges/cpp-hello-world) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |
30-
| [Input and Output](https://www.hackerrank.com/challenges/cpp-input-and-output) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |
31-
| [Basic Data Types](https://www.hackerrank.com/challenges/c-tutorial-basic-data-types) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |
32-
| [Conditional Statements](https://www.hackerrank.com/challenges/c-tutorial-conditional-if-else) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |
19+
| [Say "Hello World" with C++](https://www.hackerrank.com/challenges/cpp-hello-world) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)](introduction/say_hello_world_with_cpp.cpp) |
20+
| [Input and Output](https://www.hackerrank.com/challenges/cpp-input-and-output) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)](introduction/input_and_output.cpp) |
21+
| [Basic Data Types](https://www.hackerrank.com/challenges/c-tutorial-basic-data-types) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)](introduction/basic_data_types.cpp) |
22+
| [Conditional Statements](https://www.hackerrank.com/challenges/c-tutorial-conditional-if-else) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)](introduction/conditional_statements.cpp) |
3323
| [For Loop](https://www.hackerrank.com/challenges/c-tutorial-for-loop) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |
3424
| [Functions](https://www.hackerrank.com/challenges/c-tutorial-functions) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |
3525
| [Pointer](https://www.hackerrank.com/challenges/c-tutorial-pointer) | Easy | [![cpp](https://img.icons8.com/color/35/000000/c-plus-plus-logo.png)]() |

introduction/basic_data_types.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
#include <iomanip>
3+
4+
using namespace std;
5+
6+
int main() {
7+
int integer;
8+
long bigInteger;
9+
char character;
10+
float decimal;
11+
double precision;
12+
13+
cin >> integer >> bigInteger >> character >> decimal >>precision ;
14+
cout << integer << "\n" << bigInteger << "\n" << character << "\n";
15+
cout<<fixed<<setprecision(3)<< decimal <<"\n";
16+
cout<<fixed<<setprecision(9)<< precision <<"\n";
17+
return 0;
18+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <iomanip>
3+
4+
using namespace std;
5+
6+
int main() {
7+
int number;
8+
cin >> number;
9+
switch (number) {
10+
case 1: cout << "one";
11+
break;
12+
case 2: cout << "two";
13+
break;
14+
case 3: cout << "three";
15+
break;
16+
case 4: cout << "four";
17+
break;
18+
case 5: cout << "five";
19+
break;
20+
case 6: cout << "six";
21+
break;
22+
case 7: cout << "seven";
23+
break;
24+
case 8: cout << "eight";
25+
break;
26+
case 9: cout << "nine";
27+
}
28+
29+
if (number > 9) {
30+
cout << "Greater than 9";
31+
}
32+
}

introduction/input_and_output.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int a, b, c;
6+
cin >> a >> b >> c;
7+
cout << a + b + c;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
cout << "Hello, World!";
6+
}

main.cpp

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
#include <iostream>
2+
#include <iomanip>
3+
4+
using namespace std;
25

36
int main() {
4-
std::cout << "Hello, World!" << std::endl;
5-
return 0;
7+
int number;
8+
cin >> number;
9+
switch (number) {
10+
case 1: cout << "one";
11+
break;
12+
case 2: cout << "two";
13+
break;
14+
case 3: cout << "three";
15+
break;
16+
case 4: cout << "four";
17+
break;
18+
case 5: cout << "five";
19+
break;
20+
case 6: cout << "six";
21+
break;
22+
case 7: cout << "seven";
23+
break;
24+
case 8: cout << "eight";
25+
break;
26+
case 9: cout << "nine";
27+
}
28+
29+
if (number > 9) {
30+
cout << "Greater than 9";
31+
}
632
}

0 commit comments

Comments
 (0)