Pt1420 Unit 6 Essay

1340 Words6 Pages

Question no 1: % It is a program which takes coordinates (x, y) of a center of a circle and its radius r from user, % and determine that whether any point z with lies inside the circle, on the circle or outside the % circle. For this if ,elseif and else statements will be used there. function result= circle() x=input('Enter value of x Cordinate:'); y=input('Enter value of y Cordinate:'); r=input('Enter value of Radius:'); c=r*r; z=x*x+y*y; if c==z fprintf('The point is on the Circle'); elseif c>z fprintf('The point is outside the Circle'); else fprintf('The point is inside the Circle'); …show more content…

end Output: Question no 2: function m=ques2() x=input('Enter no of Rows: '); y=input('Enter no of columns '); for i=1:x %loop for rows for j=1:y %loop for columns str=['Enter elements in row' num2str(i) ',col' num2str(j) ': '] ; % Input values a(i,j)=input(str); end end display(a); % Call display function end function b=display(a) %Display function b=5*a; disp(b); end …show more content…

switch a %switch statement case 't' n1 = input('Enter number '); n2 = input('Enter number '); Table(n1,n2); % call of Table(); case 'f' n3 = input('Enter number '); Factorial(n3); % call of Factorial(); case 'p' n4 = input('Enter number '); Prime(n4); % call of Prime(); case 's' n5 =char([]); fprintf('Enter Array of characters \n'); for i=1:1:5 n5(i) = input (''); end c = input('Enter character to be searched:'); fprintf(' ******************************* \n '); fprintf(' Menu for Search \n '); fprintf(' ******************************* \n '); fprintf('s: for sequntial search \n'); fprintf('b: for binary search \n'); choice = input('Enter choice: '); Search(n5, c, choice); % call of Search(); otherwise fprintf('Invalid choice'); end end Output: % /////////// Funtion of Table Printing //////////// function x=Table(n1,n2)

More about Pt1420 Unit 6 Essay