Write a script to calculate the volume of a pyramid V 13 b
Solution
% matlab code to determine the volume
length = input(\"Enter the length of the base: \");
 choice = input(\"Is that i or c? \", \'s\');
 if choice == \'c\'
     length = length/2.54;
 end
 width = input(\"Enter the width of the base: \");
 choice = input(\"Is that i or c? \", \'s\');
 if choice == \'c\'
     width = width/2.54;
 end
 height = input(\"Enter the height: \");
 choice = input(\"Is that i or c? \", \'s\');
 if choice == \'c\'
     height = height/2.54;
 end
volume = (1/3)*length*width*height;
 fprintf(\"The volume of the pyramid is %0.3f cubic inches\ \",volume);
%{
 output:
Enter the length of the base: 50
 Is that i or c? i             
  Enter the width of the base: 6
 Is that i or c? c             
  Enter the height: 4           
  Is that i or c? i             
  The volume of the pyramid is 157.480 cubic inches
%}

