-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
std::cout << "Please enter \"y\" or \"n\": "; | ||
char choice{}; | ||
std::cin >> choice; | ||
if (static_cast<int16_t>(choice) == 121) { | ||
std::cout << "You've selected Yes!!" << "\n"; | ||
} else if (static_cast<int16_t>(choice) == 110) { | ||
std::cout << "You've selected No!!" << "\n"; | ||
} else { | ||
std::cout << "Damit.. You didn't follow directions..!" << "\n"; | ||
} | ||
std::cout << "Please insert any letter from alphabet: "; | ||
char userInput{}; | ||
std::cin >> userInput; | ||
std::cout << "the letter " << userInput << " translates to " << static_cast<int16_t>(userInput) << " in ASCII!" << "\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
#include "constants.h" | ||
|
||
int main() | ||
{ | ||
constexpr int16_t myBirthday{7}; // constant resolved during compile-time | ||
std::cout << "My birthday is on the: " << myBirthday << "th!" << "\n"; | ||
std::cout << "What day is your birthday?: "; | ||
int16_t x{}; | ||
std::cin >> x; | ||
const int16_t z{x}; // constant resolved during run-time | ||
std::cout << "My birthday is on the: " << z << "th!" << "\n"; | ||
if (z == myBirthday) { | ||
std::cout << "You have the same birthday as me!! \n"; | ||
} else { | ||
std::cout << "You're definitely not as cool as me...\n"; | ||
} | ||
std::cout << "Sonja's birthday is on the " << constants::sonjaBirthday << "\n"; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef CONSTANTS_H | ||
#define CONSTANTS_H | ||
|
||
namespace constants { | ||
const double pi(3.14159); | ||
const int16_t sonjaBirthday{25}; | ||
} | ||
#endif |