diff --git a/cplusplus/max_sum_contiguous_subarray.cpp b/cplusplus/max_sum_contiguous_subarray.cpp new file mode 100644 index 00000000..dbc1f4d8 --- /dev/null +++ b/cplusplus/max_sum_contiguous_subarray.cpp @@ -0,0 +1,15 @@ +#include +using namespace std; + +int main(){ + int n; + cout<<"Enter no of elements\n"; + cin>>n; + int arr[n]; + cout<<"Enter the elements\n"; + for(int i=0;i>arr[i]; + int start=0,end=0,sum=0,maxsum=0; + for(int i=0;imaxsum){ maxsum=sum; end=i; } } + cout<<"Max sum starts from "<