I am new to C++ programming and had written this C++ code:
//colpitts high freq 1 GHz working with delay
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
const double pi = 3.1415926;
int main(){
    double c0, dx, dt,C1,C2,L,fs,Ceq, freq, tau, Rload, gload, Re, ge,gm,gc1,gc2,ic1,ic2,il,gl ;
    c0=20000000000;
    dx=0.01;
    dt=dx/(2 * c0);
    cout<<dt<<"\n";
    double V1 [1000000]={};
    double V2 [1000000]={};
    V1[0]=1e-3; 
    C1=1e-12;
    C2=5e-12;
    L=30.4e-9;
    fs=4e12;
    Ceq=(C1 * C2)/(C1+C2);
    cout<<Ceq<<"\n";
    freq=1/(2 * pi * (sqrt(L*Ceq)));
    cout<<freq<<"\n";
    tau=1/freq;
    cout<<tau<<"\n";
    Rload=50;
    Re=1e6; 
    ge=1/Re;
    cout<<ge<<"\n";
    gm=0;
    gc1=(C1)/dt;
    cout<<gc1<<"\n";
    ic1=-((C1)/dt) * V1[0];  
    cout<<ic1<<"\n";
    gc2=(C2)/dt;
    cout<<gc2<<"\n";
    ic2=-((C2)/dt) * V2[0];
    cout<<ic2<<"\n";
    gl=dt/(L);
    cout<<gl<<"\n";
    il=gl * (V2[0]-V1[0]);
    cout<<il<<"\n";
    gload=1/Rload;
    cout<<gload<<"\n";
    return (0);
}
when i run it on a Linux machine, it throws an error of segmentation fault (core dumped), but when I change the array to 100000, no error is thrown and the program executes as expected. I know the problem is with physical memory allocated to me, but would there be a way around it? Can someone kindly guide me as to what modifications i need to bring in?
 
     
     
     
     
    