diff --git a/C++/Question-1.cpp b/C++/Question-1.cpp index 3373a60..bc8d9f8 100644 --- a/C++/Question-1.cpp +++ b/C++/Question-1.cpp @@ -3,8 +3,8 @@ void bubbleSort(int arr[], int n) { for (int i = 0; i < n; i++) { - for (int j = i; j < n - i - 1; j++) { - if (arr[j] < arr[j + 1]) { + for (int j = 0; j < n - i - 1; j++) { + if (arr[j] > arr[j + 1]) { // greater element should be in right most side for increasing order int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; diff --git a/C++/Question-1.exe b/C++/Question-1.exe new file mode 100644 index 0000000..59fc23e Binary files /dev/null and b/C++/Question-1.exe differ diff --git a/C++/Question-2.cpp b/C++/Question-2.cpp index b2e8ef2..a35f884 100644 --- a/C++/Question-2.cpp +++ b/C++/Question-2.cpp @@ -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; diff --git a/C++/Question-2.exe b/C++/Question-2.exe new file mode 100644 index 0000000..03ca348 Binary files /dev/null and b/C++/Question-2.exe differ diff --git a/C++/Question-3.cpp b/C++/Question-3.cpp index e6116b7..9419ece 100644 --- a/C++/Question-3.cpp +++ b/C++/Question-3.cpp @@ -13,7 +13,7 @@ void guessNumber() { 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; diff --git a/C++/Question-3.exe b/C++/Question-3.exe new file mode 100644 index 0000000..5c28a1f Binary files /dev/null and b/C++/Question-3.exe differ diff --git a/C++/Question-4.cpp b/C++/Question-4.cpp index 83db22b..e397472 100644 --- a/C++/Question-4.cpp +++ b/C++/Question-4.cpp @@ -5,7 +5,20 @@ #include bool checkPassword(std::string password) { - return password.length() >= 8; + if(password.length() >= 8){ + int x=0; + int y=0; + for(int i=0;i=65 && int(password[i])<=90) || (int(password[i])>=97 && int(password[i])<=122) ){ + x=1; + } + else{ + y=1; + } + } + if(x==1 && y==1) return true; + } + return false; } int main() { @@ -22,3 +35,5 @@ int main() { return 0; } + + \ No newline at end of file diff --git a/C++/Question-4.exe b/C++/Question-4.exe new file mode 100644 index 0000000..96d91eb Binary files /dev/null and b/C++/Question-4.exe differ diff --git a/C++/Question-5.cpp b/C++/Question-5.cpp index 036a83c..ec535a1 100644 --- a/C++/Question-5.cpp +++ b/C++/Question-5.cpp @@ -2,6 +2,7 @@ // Function to calculate the factorial of a number int factorial(int n) { + if(n==1 || n==0) return 1; return n * factorial(n - 1); } diff --git a/C++/Question-5.exe b/C++/Question-5.exe new file mode 100644 index 0000000..b4be681 Binary files /dev/null and b/C++/Question-5.exe differ