diff --git a/.vscode/settings.json b/.vscode/settings.json index 0c83701..310750d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,78 @@ { "files.associations": { "iostream": "cpp", - "ostream": "cpp" + "ostream": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "cfenv": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cuchar": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "scoped_allocator": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "valarray": "cpp", + "variant": "cpp" } } \ No newline at end of file diff --git a/Binary_to_Decimal.cpp b/Binary_to_Decimal.cpp new file mode 100644 index 0000000..d489392 --- /dev/null +++ b/Binary_to_Decimal.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +using namespace std; + +int main() +{ + string str, str2; + int j = 0, sum =0, i=0; + cin >> str; + int len = str.length(); + reverse(str.begin(), str.end()); + while(j!=(len) && i!=len) { + str2 = str[i]; + stringstream convert(str2); + int x; + convert >> x; + sum = sum + (x*pow(2,j)); + j++; + i++; + } + cout << sum; +} \ No newline at end of file diff --git a/Binary_to_Decimal.exe b/Binary_to_Decimal.exe new file mode 100644 index 0000000..a2855e4 Binary files /dev/null and b/Binary_to_Decimal.exe differ diff --git a/Binary_to_Octal_other_Method.cpp b/Binary_to_Octal_other_Method.cpp new file mode 100644 index 0000000..ccabd97 --- /dev/null +++ b/Binary_to_Octal_other_Method.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +using namespace std; + +int main() +{ + int binary; + cin >> binary; + int i = 0, octal = 0, decimal = 0; + while(binary!=0){ + decimal = decimal + ((binary%10)*pow(2, i)); + i++; + binary = int(binary/10); + } + i = 1; + while(decimal!=0){ + octal = octal + ((decimal%8)*i); + decimal = int(decimal/8); + i = i*10; + } + cout << octal; +} \ No newline at end of file diff --git a/Binary_to_Octal_other_Method.exe b/Binary_to_Octal_other_Method.exe new file mode 100644 index 0000000..dab1f63 Binary files /dev/null and b/Binary_to_Octal_other_Method.exe differ diff --git a/Circumference_of_Circle.cpp b/Circumference_of_Circle.cpp new file mode 100644 index 0000000..ce9a3b0 --- /dev/null +++ b/Circumference_of_Circle.cpp @@ -0,0 +1,11 @@ +#include +#include +using namespace std; + +int main() +{ + float r, circumference; + cin >> r; + circumference = (2*3.14*r); + cout << fixed << setprecision(2) << circumference; +} \ No newline at end of file diff --git a/Circumference_of_Circle.exe b/Circumference_of_Circle.exe new file mode 100644 index 0000000..0f5c51d Binary files /dev/null and b/Circumference_of_Circle.exe differ diff --git a/Decimal_to_Octal.cpp b/Decimal_to_Octal.cpp new file mode 100644 index 0000000..0c22dd7 --- /dev/null +++ b/Decimal_to_Octal.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +using namespace std; + +int main() +{ + int decimal; + cin >> decimal; + int i, octal = 0; + i = 1; + while(decimal!=0){ + octal = octal + ((decimal%8)*i); + decimal = int(decimal/8); + i = i*10; + } + cout << octal; +} \ No newline at end of file diff --git a/Decimal_to_Octal.exe b/Decimal_to_Octal.exe new file mode 100644 index 0000000..e9e2f20 Binary files /dev/null and b/Decimal_to_Octal.exe differ diff --git a/Fibonacci_Series.cpp b/Fibonacci_Series.cpp new file mode 100644 index 0000000..d965dd0 --- /dev/null +++ b/Fibonacci_Series.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ + int n, t1=0, t2=1, tn; + cin >> n; + for (int i=0; i +using namespace std; + +int main() +{ + int n1, n2, n3; + cin >> n1; + cin >> n2; + cin >> n3; + if(n1>=n2 && n1>=n3){ + cout << n1; + } else if(n2>=n1 && n2>=n3) { + cout << n2; + } else{ + cout << n3; + } +} \ No newline at end of file diff --git a/Greatest_Of_Three_Numbers.exe b/Greatest_Of_Three_Numbers.exe new file mode 100644 index 0000000..0abb4ed Binary files /dev/null and b/Greatest_Of_Three_Numbers.exe differ diff --git a/Length_of_String.exe b/Length_of_String.exe index 008c51f..31fec27 100644 Binary files a/Length_of_String.exe and b/Length_of_String.exe differ diff --git a/Nth_Fibonacci_Number.cpp b/Nth_Fibonacci_Number.cpp new file mode 100644 index 0000000..1412f9c --- /dev/null +++ b/Nth_Fibonacci_Number.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +int main() +{ + int n, t1=0, t2=1, tn; + cin >> n; + for (int i=0; i +using namespace std; + +bool palindrome(string str) { + int len = str.length(); + int mid = len/2; + for (int i=0; imid; j--) + if(str[i]==str[j]) + return true; + return false; +} + +int main() +{ + std::string str; + std::getline(std::cin, str); + palindrome(str) ? cout << "Palindrome" : cout << "Not a Palindrome"; +} \ No newline at end of file diff --git a/Palindrome.exe b/Palindrome.exe new file mode 100644 index 0000000..653e3ca Binary files /dev/null and b/Palindrome.exe differ diff --git a/Palindrome_Other_Method.cpp b/Palindrome_Other_Method.cpp new file mode 100644 index 0000000..8c4c98b --- /dev/null +++ b/Palindrome_Other_Method.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +using namespace std; + +bool palindrome(string str1, string str2) { + if(str1 == str2) + return true; + return false; +} + +int main() +{ + std::string str1, str2; + std::getline(std::cin, str1); + str2 = str1; + reverse(str2.begin(), str2.end()); + palindrome(str1, str2) ? cout << "Palindrome" : cout << "Not a Palindrome"; +} \ No newline at end of file diff --git a/Palindrome_Other_Method.exe b/Palindrome_Other_Method.exe new file mode 100644 index 0000000..87b75ff Binary files /dev/null and b/Palindrome_Other_Method.exe differ diff --git a/Reverse_Number_other_Logic.cpp b/Reverse_Number_other_Logic.cpp new file mode 100644 index 0000000..b399574 --- /dev/null +++ b/Reverse_Number_other_Logic.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; + +int main() +{ + int n, reverse = 0, remainder; + cin >> n; + while(n != 0) + { + remainder = n % 10; + reverse = (reverse*10) + remainder; + n = n / 10; + } + cout << reverse; +} \ No newline at end of file diff --git a/Reverse_Number_other_Logic.exe b/Reverse_Number_other_Logic.exe new file mode 100644 index 0000000..36452eb Binary files /dev/null and b/Reverse_Number_other_Logic.exe differ diff --git a/Reverse_the_given_Number.cpp b/Reverse_the_given_Number.cpp new file mode 100644 index 0000000..323af77 --- /dev/null +++ b/Reverse_the_given_Number.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +using namespace std; + +int main() +{ + string str, str2; + int i; + cin >> str; + int len = str.length(); + reverse(str.begin(), str.end()); + if(str[0]=='0'){ + for(int j=1; j<=len; j++){ + cout << str[j]; + } + } else { + cout << str; + } +} \ No newline at end of file diff --git a/Reverse_the_given_Number.exe b/Reverse_the_given_Number.exe new file mode 100644 index 0000000..6fbd357 Binary files /dev/null and b/Reverse_the_given_Number.exe differ diff --git a/Roots_of_Quadratic_Equation.cpp b/Roots_of_Quadratic_Equation.cpp new file mode 100644 index 0000000..1fbab39 --- /dev/null +++ b/Roots_of_Quadratic_Equation.cpp @@ -0,0 +1,17 @@ +#include +#include +#include +using namespace std; + +int main() +{ + int a, b, c; + float root1, root2, diff; + cin >> a; + cin >> b; + cin >> c; + diff = b*b-4*a*c; + root1 = (-b+sqrt(diff))/(2*a); + root2 = (-b-sqrt(diff))/(2*a); + cout << "root1 = " << fixed << setprecision(2) << root1 << " " << "root2 = " << fixed << setprecision(2) << root2; +} \ No newline at end of file diff --git a/Roots_of_Quadratic_Equation.exe b/Roots_of_Quadratic_Equation.exe new file mode 100644 index 0000000..b082157 Binary files /dev/null and b/Roots_of_Quadratic_Equation.exe differ diff --git a/Second_Greatest_of_Three_Numbers.cpp b/Second_Greatest_of_Three_Numbers.cpp new file mode 100644 index 0000000..a95c5f3 --- /dev/null +++ b/Second_Greatest_of_Three_Numbers.cpp @@ -0,0 +1,21 @@ +#include +using namespace std; + +int main() +{ + int n1, n2, n3; + cin >> n1; + cin >> n2; + cin >> n3; + if((n1>n2 && n1n3) || (n1==n2 && n1n1 && n2n3) || (n1==n3 && n1>n2)) { + cout << n2; + } + else if(n1==n2 && n1>n3) { + cout << n3; + } + else{ + cout << n3; + } +} \ No newline at end of file diff --git a/Second_Greatest_of_Three_Numbers.exe b/Second_Greatest_of_Three_Numbers.exe new file mode 100644 index 0000000..0bce336 Binary files /dev/null and b/Second_Greatest_of_Three_Numbers.exe differ diff --git a/Simple_Interest.exe b/Simple_Interest.exe index 9406ede..9e12b7b 100644 Binary files a/Simple_Interest.exe and b/Simple_Interest.exe differ diff --git a/String_Palindrome.cpp b/String_Palindrome.cpp new file mode 100644 index 0000000..e52c094 --- /dev/null +++ b/String_Palindrome.cpp @@ -0,0 +1,19 @@ +#include +#include +#include +using namespace std; + +bool palindrome(string str1, string str2) { + if(str1 == str2) + return true; + return false; +} + +int main() +{ + std::string str1, str2; + std::getline(std::cin, str1); + str2 = str1; + reverse(str2.begin(), str2.end()); + palindrome(str1, str2) ? cout << str1 << " is a palindrome" : cout << str1 << " is not a palindrome"; +} \ No newline at end of file diff --git a/String_Palindrome.exe b/String_Palindrome.exe new file mode 100644 index 0000000..9c788cf Binary files /dev/null and b/String_Palindrome.exe differ diff --git a/String_Reverse_using_Recursion.cpp b/String_Reverse_using_Recursion.cpp new file mode 100644 index 0000000..0a9808c --- /dev/null +++ b/String_Reverse_using_Recursion.cpp @@ -0,0 +1,22 @@ +#include +#include +using namespace std; + +void reverse(string str) +{ + int len = str.length(); + if(len==1) + cout<