A problem soving question & form-componet with validation and popup
For example, Input: { -6, 4, - 5, 8, -10, 0, 8 } Output: 1600 Explanation: The maximum product subarray is {4, -5, 8, -10} having product 1600 Input: {40,9,-20,-10} Output: 200 Explanation: The maximum product subarray is {-20, -10} having product 200
// Online C++ compiler to run C++ program online
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cout<<"Enter the size of the array: ";
cin>>n;
int arr[n];
cout<<"Enter the element of the array: ";
for(int i=0;i<n;i++){
cin>>arr[i];
}
int pref=1, suff=1;
int ans=INT_MIN;
for(int i=0;i<n;i++){
if(pref==0){
pref=1;
}
if(suff==0){
suff=1;
}
pref=pref*arr[i];
suff=suff*arr[n-1-i];
ans=max(ans,max(pref,suff));
}
cout<<"Maximum subarray product is: "<<ans<<endl;
return 0;
}
Requirements : Students Details: Roll No, Name, Age, Email, Mob Number.
**Also Add Validation For The Student Fields. After Submitting Form, Show Student Details In A Popup. **