s0 =input('Enter the stock price at t = 0 : S0 =  ');
k = input('Enter the strike price for underlying asset ');
r = input('Enter the risk free rate of interest ');
T=  input('Enter the expiry time ');
sigma=input('Enter the volatility for underlying asset ');
 
lso = (log(s0/k)+(r+(sigma.*sigma)/2)*T);
d1 = lso/(sigma*sqrt(T));
d2 = d1 - sigma*sqrt(T);
fprintf('1 : call option \n 2 : put option \n ');
ch = input(' choice for put or call ');
if ch == 1 % call option
    c0 = s0*normcdf(d1)-k*exp(-r*T)*normcdf(d2);
    fprintf('\nThe value of call option price is C0 = %f\n',c0);
end
if ch == 2 % put option
    c0 = s0*normcdf(d1)-k*exp(-r*T)*normcdf(d2);
    p0 = c0-s0+k*exp(-r*T);
    fprintf('\nThe value of put option price is C0 = %4.4f\n',p0);
end

