1.
temperature = input('Please enter the temperature: ');
units = input('Please enter the units of Temperature (C or F): ','s');
if (units == 'F' || units == 'f')
converted = (temperature-32)*(5/9);
convertedto = 'C';
elseif (units == 'C' || units == 'c')
converted = temperature*(9/5) + 32;
convertedto = 'F';
else
fprintf('\nYou have given a wrong input\n')
fprintf('The program will restart again\n')
fprintf('----------RESTART - FCF.M --------- \n\n')
fcf
end
fprintf('%.2f %s = %.2f %s\n',temperature,
upper(units),converted,convertedto)
2.
x=input('Enter a number');
t=1;
for i=1:x
t=t*i;
end
disp(t)
3.
N = input('Enter a number')
s = (-1)^N;
if s == -1
disp('N is odd')
else
disp('N is even')
end
4.
name = 'Sandeep';
x = input('Number of times to display your name');
for i = 1:x
display(name);
end