0% found this document useful (0 votes)
11 views3 pages

Code

work of education

Uploaded by

Aman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Code

work of education

Uploaded by

Aman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Data types: int, char, float. Use of variables......................................................................................

1
conditional if-else..............................................................................................................................1
Five Logical operators........................................................................................................................1
Five Arithmetic operators..................................................................................................................2
Declaration and definition of functions.............................................................................................2

clc;clear all;close all;

Data types: int, char, float. Use of variables


a=10; % int variable
b=20.908; % float point variable
c='J'; % char variable

conditional if-else
if a>b % if true
disp('Value "a" is greater then value of "b"')
else % else
disp('Value "a" is not greater then value of "b"')
end

Value "a" is not greater then value of "b"

Five Logical operators


x1=(b ~= 0) % logical operator
x2=(a/b > 1.5) % logical operator
x3=(b ~= 0) && (a/b > 1.5) % logical operatora
x4=(b ~= 0) || (a/b > 1.5) % logical operatora
x5= (c=='J') % logical operator

x1 =

logical

x2 =

logical

x3 =
logical

x4 =

logical

x5 =

logical

Five Arithmetic operators


[first_arth,sec_arth,third_arth,fourth_arth,fifth_arth] = five_arthemtaics(a,b) % Calling functions

Declaration and definition of functions


function [Sum,Subtraction,Divide_A_B,Multiplication,Divide_B_A] = five_arthemtaics(a,b)
Sum=a+b; % sum of a and b
Subtraction=a-b; % subtraction of a to b
Divide_A_B=a/b; % divides every element in A by the same element in B
Multiplication=a.*b; % multiplication a and b
Divide_B_A=a.\b; % divides every element in B by the same element in A
end

first_arth =

30.9080

sec_arth =

-10.9080

third_arth =

0.4783
fourth_arth =

209.0800

fifth_arth =

2.0908

You might also like