diff --git a/C++/m1.cpp b/C++/m1.cpp index caa5f1c..3296f6c 100644 --- a/C++/m1.cpp +++ b/C++/m1.cpp @@ -8,8 +8,7 @@ class Solution public: bool isPalindrome(string s) { - int i = 0, j = s.size(); - + int i = 0, j = s.size()-1; while (i < j) { if (s[i++] != s[j--]) diff --git a/C++/m3.cpp b/C++/m3.cpp index d6995fd..720fc18 100644 --- a/C++/m3.cpp +++ b/C++/m3.cpp @@ -2,11 +2,11 @@ #include using namespace std; - + char string1[80]; char *initialize() { - char string[80]; + // string = "hello" - char* ptr = string; + char* ptr = &string1[0]; return ptr; } @@ -17,6 +17,7 @@ void do_something_with(char* myval){ main() { cout << "enter value for myval" << endl; char *myval = initialize(); + cout<<"Address is "<> *myval; cout << "Variable intialized" << endl; do_something_with(myval); diff --git a/C++/m3.exe b/C++/m3.exe new file mode 100644 index 0000000..76b0477 Binary files /dev/null and b/C++/m3.exe differ diff --git a/C++/m6.cpp b/C++/m6.cpp index 5524bce..98eb238 100644 --- a/C++/m6.cpp +++ b/C++/m6.cpp @@ -4,7 +4,7 @@ #include int main(){ - std :: string s = "Hello World"; + std :: string s = "Hello World!"; for(int i=0;i < s.length(); i++){ s[i] = toupper(s[i]); diff --git a/C++/m6.exe b/C++/m6.exe new file mode 100644 index 0000000..8b6a6ff Binary files /dev/null and b/C++/m6.exe differ diff --git a/C++/s1.cpp b/C++/s1.cpp index 95629da..2e0b066 100644 --- a/C++/s1.cpp +++ b/C++/s1.cpp @@ -6,7 +6,7 @@ using namespace std; int reverse(int x) { long r=0; while(x){ - r=r*10+x/10; + r=r*10+x%10; x=x/10; } return r; diff --git a/C++/s1.exe b/C++/s1.exe new file mode 100644 index 0000000..7ea9df7 Binary files /dev/null and b/C++/s1.exe differ diff --git a/C++/s3.cpp b/C++/s3.cpp index 854ed28..d7cc895 100644 --- a/C++/s3.cpp +++ b/C++/s3.cpp @@ -18,7 +18,6 @@ void ineedj(void) { } main() { - int j; j = foo(i); ineedj(); } diff --git a/C++/s3.exe b/C++/s3.exe new file mode 100644 index 0000000..619903a Binary files /dev/null and b/C++/s3.exe differ diff --git a/C++/s4.exe b/C++/s4.exe new file mode 100644 index 0000000..3d4c3dc Binary files /dev/null and b/C++/s4.exe differ diff --git a/C++/s5.cpp b/C++/s5.cpp index 3c05697..a51a3e3 100644 --- a/C++/s5.cpp +++ b/C++/s5.cpp @@ -5,9 +5,16 @@ using namespace std; int main(void){ string string1 = "Hello"; string string2 = "Horld"; - - if (string1 == string2) - cout << "Equal"; - else - cout << "Not Equal"; + int i, flag=1; + for(i=0;i<5;i++) + { + if (string1[i] != string2[i]) + flag=0; +} + if(flag==0) + { + cout<<"Not eual"; + } + else + cout<<"Eual"; } diff --git a/C++/s5.exe b/C++/s5.exe new file mode 100644 index 0000000..b473747 Binary files /dev/null and b/C++/s5.exe differ diff --git a/Python/s1.py b/Python/s1.py index e4fbd9f..db08927 100644 --- a/Python/s1.py +++ b/Python/s1.py @@ -12,4 +12,4 @@ letter_count += 1 print("Letters:", letter_count) -print("Digits:", digit_count) +print("Digits:", digit_count) \ No newline at end of file diff --git a/Python/s4.py b/Python/s4.py index c33f313..225f7b2 100644 --- a/Python/s4.py +++ b/Python/s4.py @@ -3,10 +3,10 @@ def is_power_of_two(n): if n <= 0: return False - return (n & (n-1)) == 1 + return (n & (n-1)) == 0 -num = 69 +num = 5 if is_power_of_two(num): print(num, "is a power of 2") else: diff --git a/Python/s5.py b/Python/s5.py index 64bc40c..8606eeb 100644 --- a/Python/s5.py +++ b/Python/s5.py @@ -1,9 +1,9 @@ # Program: How are you doing? answer1 = input("Are you enjoying Vashisht? ([Y]es/[N]o) ") -if answer1.lower() == "y" or "yes": +if answer1.lower() == "y" or answer1.lower()=="yes": print("That's great! We hope you're having fun hunting for bugs.") -elif answer1.lower() == "n" or "no": +elif answer1.lower() == "n" or answer1.lower()=="no": print(":( We're sorry to hear that. We hope you'll have fun soon.") else: print("404 Not Found!") @@ -11,9 +11,9 @@ print() answer2 = input("Do you want me to print bugs for all Python files? ;) ([Y]es/[N]o) ") -if answer2.lower() == "y" or "yes": +if answer2.lower() == "y" or answer2.lower()=="yes": print("Nice try :P") -elif answer2.lower() == "n" or "no": +elif answer2.lower() == "n" or answer2.lower()=="no": print("That's the spirit!") else: print("404 Not Found!")