Using above concept Write a MATLAB program to enter marks of
Solution
%taking marks as input using the input command and casting them into double
 %type
 physics = double(input(\'Physics marks: \'));
 history = double(input(\'History marks: \'));
 psychology = double(input(\'Psychology marks: \'));
%calculating total of marks in physics, history and psychology
 total = physics + history + psychology;
%calculating average
 AVG = total/3;
 %conditions to check the average and grant appropriate grade
 if AVG >= 75
     grade = \'A\';
 elseif AVG > 50
     grade = \'B\';
 elseif AVG > 25;
     grade = \'C\';
 else
     grade = \'F\';
 end
%displaying the grade using disp and concatenating the strings using strcat
 disp(strcat(\'Grade: \', grade));
 %part I.
 %initialising the sum of squares to 0
 sum_of_squares = 0;
%for loop to iterate through the values whose sum of squares we need to
 %find
 for i=2:1:20
     sum_of_squares = sum_of_squares + i*i;
 end
%displaying the sum of squares
 disp(strcat(\'Sum of squares from 2 to 20:   \', num2str(sum_of_squares)));
%part II.
 %initialising the sum of squares to 0
 sum_of_odd_squares = 0;
%for loop to iterate through the values whose sum of squares we need to
 %find
 for i=1:2:501
     sum_of_odd_squares = sum_of_odd_squares + i*i;
 end
%displaying the sum of odd squares
 disp(strcat(\'Sum of odd squares from 1 to 501:   \', num2str(sum_of_odd_squares)));
%part III.
%Printing out the even numbers from 10 to 50.
%initialising n to 10
 n = 10;
 while n<=50
     disp(n); %displaying n
     n = n+2;
 end
 %Printing out the odd numbers from 10 to 50.
 %initialising n to 11
 n = 11;
 while n<=50
     disp(n)
     n = n+2;
 end


