Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BruteCoders #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions C++/Question-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <iostream>

void bubbleSort(int arr[], int n) {
for (int i = 0; i < n; i++) {
for (int j = i; j < n - i - 1; j++) {
for (int i = 0; i < n-1; i++) {
for (int j = 0; j < n - i-1; j++) {
if (arr[j] < arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
Expand Down
Binary file added C++/Question-1.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion C++/Question-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main() {
double convertedAmount = usdToEur(amount);
std::cout << "Amount in EUR: " << convertedAmount << std::endl;
} else if (currency == "EUR") {
double convertedAmount = usdToEur(amount);
double convertedAmount = eurToUsd(amount);
std::cout << "Amount in USD: " << convertedAmount << std::endl;
} else {
std::cout << "Invalid currency." << std::endl;
Expand Down
Binary file added C++/Question-2.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions C++/Question-3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ void guessNumber() {
std::cout << "Guess the number (between 1 and 100): ";
std::cin >> guess;

if (guess > number) {
if (guess < number) {
std::cout << "Too low! Try again." << std::endl;
} else if (guess <= number) {
} else if (guess > number) {
std::cout << "Too high! Try again." << std::endl;
} else {
std::cout << "Congratulations! You guessed the number." << std::endl;
Expand Down
Binary file added C++/Question-3.exe
Binary file not shown.
17 changes: 15 additions & 2 deletions C++/Question-4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@
#include <string>

bool checkPassword(std::string password) {
return password.length() >= 8;
int l=0,u=0,s=0;
for(int i=0;i<password.size();++i){
int c=password[i];
if(c>=65&&c<=90){
++u;
}
else if(c>=97&&c<=122){
++l;
}
else{
++s;
}
}
return (password.length() >= 8)&&(u>0)&&(l>0)&&(s>0);
}

int main() {
Expand All @@ -17,7 +30,7 @@ int main() {
if (checkPassword(password)) {
std::cout << "Password is valid." << std::endl;
} else {
std::cout << "Password is too short." << std::endl;
std::cout << "Password is invalid" << std::endl;
}

return 0;
Expand Down
Binary file added C++/Question-4.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions C++/Question-5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

// Function to calculate the factorial of a number
int factorial(int n) {
if(n<=1){
return 1;
}
return n * factorial(n - 1);
}

Expand Down
Binary file added C++/Question-5.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions C++/tempCodeRunnerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(n<=1){
return 1;
}