diff --git a/C++/h1.cpp b/C++/h1.cpp index 2d23603..daa0a4f 100644 --- a/C++/h1.cpp +++ b/C++/h1.cpp @@ -1,9 +1,11 @@ // find the longest pallindrome in the string // This program is designed to find the longest palindrome in a given string -// ie. if the string given is 'djhfacdadcaop' the longest palindrom is 'acdadca' +// ie. if the string given is 'djhfacdadcaop' the longest palindrom is 'acdadca' // which should be the return value for the function longest pallindrome(char* s). #include +#include // + using namespace std; void printSubStr( @@ -19,7 +21,7 @@ int longestPalSubstr(string str) bool table[n][n]; - memset(table, 0, sizeof(table)); + memset(table, 0, sizeof(table)); // int maxLength = 1; diff --git a/C++/h1.exe b/C++/h1.exe new file mode 100644 index 0000000..292c635 Binary files /dev/null and b/C++/h1.exe differ diff --git a/C++/h1.o b/C++/h1.o new file mode 100644 index 0000000..34b8747 Binary files /dev/null and b/C++/h1.o differ diff --git a/C++/h2.exe b/C++/h2.exe new file mode 100644 index 0000000..bd06b2f Binary files /dev/null and b/C++/h2.exe differ diff --git a/C++/h2.o b/C++/h2.o new file mode 100644 index 0000000..793ae22 Binary files /dev/null and b/C++/h2.o differ diff --git a/C++/m1.o b/C++/m1.o new file mode 100644 index 0000000..daabb59 Binary files /dev/null and b/C++/m1.o differ diff --git a/C++/m3.cpp b/C++/m3.cpp index d6995fd..e948566 100644 --- a/C++/m3.cpp +++ b/C++/m3.cpp @@ -19,5 +19,5 @@ main() { char *myval = initialize(); cin >> *myval; cout << "Variable intialized" << endl; - do_something_with(myval); + do_something_with(char * myval); } diff --git a/C++/m3.exe b/C++/m3.exe new file mode 100644 index 0000000..03750ba Binary files /dev/null and b/C++/m3.exe differ diff --git a/C++/m3.o b/C++/m3.o new file mode 100644 index 0000000..4ea5d7a Binary files /dev/null and b/C++/m3.o differ diff --git a/C++/m6.cpp b/C++/m6.cpp index 5524bce..50a22ea 100644 --- a/C++/m6.cpp +++ b/C++/m6.cpp @@ -4,7 +4,7 @@ #include int main(){ - std :: string s = "Hello World"; + std :: string s = "a . ,";//doesnt work for special characters. 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..63f6f6b Binary files /dev/null and b/C++/m6.exe differ diff --git a/C++/m6.o b/C++/m6.o new file mode 100644 index 0000000..a57952d Binary files /dev/null and b/C++/m6.o differ diff --git a/C++/s1.cpp b/C++/s1.cpp index 95629da..472a4e3 100644 --- a/C++/s1.cpp +++ b/C++/s1.cpp @@ -4,10 +4,10 @@ using namespace std; int reverse(int x) { - long r=0; + long r=0; while(x){ - r=r*10+x/10; - x=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..ddf9615 Binary files /dev/null and b/C++/s1.exe differ diff --git a/C++/s1.o b/C++/s1.o new file mode 100644 index 0000000..a893f39 Binary files /dev/null and b/C++/s1.o differ diff --git a/C++/s2.exe b/C++/s2.exe new file mode 100644 index 0000000..cc2b9e4 Binary files /dev/null and b/C++/s2.exe differ diff --git a/C++/s2.o b/C++/s2.o new file mode 100644 index 0000000..47e4735 Binary files /dev/null and b/C++/s2.o differ diff --git a/C++/s3.cpp b/C++/s3.cpp index 854ed28..d653631 100644 --- a/C++/s3.cpp +++ b/C++/s3.cpp @@ -4,7 +4,7 @@ using namespace std; int i = 5; -int j; +int j=7;//initialize j(we initialized j as 7) int foo(int j) { for (i=0; i +#include using namespace std; int main(void){ string string1 = "Hello"; - string string2 = "Horld"; - + string string2 = "Hello"; if (string1 == string2) cout << "Equal"; + else cout << "Not Equal"; } diff --git a/C++/s5.exe b/C++/s5.exe new file mode 100644 index 0000000..58b66ff Binary files /dev/null and b/C++/s5.exe differ diff --git a/C++/s5.o b/C++/s5.o new file mode 100644 index 0000000..d5206f9 Binary files /dev/null and b/C++/s5.o differ diff --git a/C++/s6.cpp b/C++/s6.cpp index 736760a..20d91df 100644 --- a/C++/s6.cpp +++ b/C++/s6.cpp @@ -5,14 +5,23 @@ using namespace std; int maxSubArraySum(int a[], int size) { int max_so_far = INT_MIN, max_ending_here; - + for (int i = 0; i < size; i++) { max_ending_here = max_ending_here + a[i]; if (max_so_far < max_ending_here) max_so_far = max_ending_here; - + if (max_ending_here < 0) max_ending_here = max_so_far; } return max_so_far; } +int main() +{ + + int arr[]={-1,-2,-3,-3,-8}; + cout<