qbasicmathoperators.doc

Upload: hussnain-awan

Post on 06-Jul-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/17/2019 QBasicMathOperators.doc

    1/6

    317035734.doc

    QBasic Lesson 4: QBasic’s Math Operators (7)

    OBJECTIVES:

    • Using QBasic Math O!"ato"s

    • Us! O"d!" o# O!"ation

    • Sto"! th! "!s$%ts o# ca%c$%ations in &a"ia'%!s

    • ("int th! "!s$%t o# ca%c$%ations

    ) Math Operator is a s*+'o% $s! #o" addition, s$'t"action, +$%ti%ication, di&ision, o" oth!"ca%c$%ations

    The QBasic math operators and their meanings.

    Symbo Meaning

    - M$%ti%ication

    /i&ision

    )ddition

    S$'t"action

    2 Eon!ntiation

    Int!g!" di&ision

    MO/ Mod$%$s

    o$ can not $s! th! 6 #o" +$%ti%ication '!ca$s! QBasic "!ads it as a &a"ia'%!.

    o$ can $s! th! addition and s$'t"action o!"ato"s '* th!+s!%&!s to indicat! ositi&! and n!gati&!

    n$+'!"s. 8o" this "!ason th! addition and s$'t"action o!"ato"s a"! ca%%!d !nary operators.

    o$ $s! int!g!" di&ision to "od$c! th! int!g!" 9o" ho%!n$+'!"; "!s$%t o# a di&ision. Int!g!"di&ision a%a*s "od$c!s an int!g!" "!s$%t and disca"ds an* "!+aind!". o$ do not ha&! to $t Int!g!"s on 'oth sid!s o# th! s%ash 9; .

    "#ampe: ($%&'47.%)

    orm!a *es!ts

    5= 47

    >5.0= 47

    >5=.0 47>5.0=.0 47

     

  • 8/17/2019 QBasicMathOperators.doc

    2/6

    317035734.doc

    Th! MO+ o!"ato" do!s not $s! a s*+'o%. MO+ "od$c!s th! +od$%$s, o" int!g!" "!+aind!", o#di&ision.

    "#ampe:

    orm!a MO+

    *es!ts

    +i,ision

    *es!t

    < MO/ = -

  • 8/17/2019 QBasicMathOperators.doc

    3/6

    317035734.doc

    Order o0 Operation

    Order Operator

    1 Eon!ntiation 92;

    = Una"* )ddition and S$'t"action

    3 M$%ti%ication, di&ision, int!g!" di&ision, MO/ 9 -, , , MO/;

    4 )ddition, s$'t"action

    I# *o$ ant to o,erride the order o0 operation, $t a"!nth!s!s in th! ca%c$%ations.

    Can *o$ #ind th! !""o" in th! #o%%oing cod!

     2 %ompte the average of three grades

    L"T grade 56 

    L"T grade' $5

    L"T grade@ 7@

    L"T a,g grade A grade' A grade@ & @

    *;

  • 8/17/2019 QBasicMathOperators.doc

    4/6

    317035734.doc

    @!&i! Q$!stions

    1. Dhat a"! th! "!s$%ts o# th! #o%%oing !"!ssionsa. 1 = - 4 =b. 9 1 = ; - 4 =c. 1 = - 9 4 = ;

    =. Dhat a"! th! "!s$%ts o# th! #o%%oing !"!ssionsa. > = 1b. 9 1 910 9 = = ;;;

    3. Dhat is th! o$t$t o# th! #o%%oing cod!

     

    L"T a 6 

    L"T b -

    *;

  • 8/17/2019 QBasicMathOperators.doc

    5/6

    317035734.doc

    @!&i! Q$!stion )FSDE@S

    7. Dhat a"! th! "!s$%ts o# th! #o%%oing !"!ssionsa. 1 = - 4 = ? %b. 9 1 = ; - 4 = ? 6c. 1 = - 9 4 = ; ? %

  • 8/17/2019 QBasicMathOperators.doc

    6/6

    317035734.doc

    Lesson 4 "#ercises

    8o" !ach o# th! #o%%oing "og"a+s +aG! s$"! *o$ $s! "!+a"Gs and c%!a" th! sc"!!n h!"!n!c!ssa"*. Sa&! a co* o# !ach to *o$" ho+! #o%d!". T$"n in a ha"dco* o# !ach "og"a+s "int o$tthat inc%$d!s *o$" na+! on th! #i"st %in!, th! "og"a+ na+! on th! s!cond %in! and #o%%o!d '* #o$"

     '%anG %in!s '!#o"! th! "int o$t o# th! "og"a+ a!a"s. )%so t$"n in a ha"dco* o# th! "og"a+cod! and th! cod! on disG.

    1. D"it! and sa&! a "og"a+ 9E!"4H1.'as; that "ints !ach o# th! #i"st nin! o!"s o# =, '!ginning ith th! !"o o!". Us! th! a"o"iat! "!+a"Gs at th! '!ginning o# *o$" "og"a+. C%!a" th! sc"!!n in th! a"o"iat! %ac!. ("int st"ing constants that d!sc"i'! !ach "int!d ans!" as #o%%os: = "ais!d to th! !"o o!" is 1

    =. D"it! and sa&! a "og"a+ 9E!"4H=.'as; that co+$t!s and "ints a 'on$s o# 15 !"c!nt o#th! g"oss a* #o" John S+ith. /ont taG! ta!s o$t o# th! 'on$s. )#t!" "inting th! #o$"

    &a"ia'%!s, g"oss(a*, ta!s, 'on$s and n!t(a*, "int a a*ch!cG to th! "int!". )dd st"ingconstants so that th! ch!cG inc%$d!s th! na+! o# th! a*!!. ("int *o$" na+! as th! a*o" atth! 'otto+ o# th! ch!cG. (a* !" ho$" is K1=.00. Ta "at! is 33L. John is a #$%% ti+!!+%o*!! o"Ging 40 ho$"s !" !!G. ! g!ts aid !&!"* oth!" !!G.

    3. Sto"! th! na+!s, !ights, h!ights and ag!s o# th"!! !o%! in &a"ia'%!s. ("int a ta'%! ithtit%!s and th! na+!s, !ights, h!ights and ag!s o# a%% th"!! !o%!. )t th! 'otto+ o# th!ta'%!, "int th! a&!"ag! !ights, h!ights and ag!s. 9E!"4H3.'as;

    4. )ss$+! that a &id!osto"! !+%o*!! o"Gs 50 ho$"s d$"ing a a* !"iod. Th! !+%o*!! is aid K5.50 #o" th! #i"st 40 ho$"s. Sh! g!ts ti+!andaha%# a* #o" th! #i"st #i&! ho$"s o&!"40. Sh! g!ts aid do$'%! ti+! #o" ho$"s o&!" 45. )ss$+ing a =