Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Maths in QBASIC-I

Maths in QBASIC-I

Later I will

Nishan Lamichhane

May 07, 2020
Tweet

More Decks by Nishan Lamichhane

Other Decks in Education

Transcript

  1. 451 MOD 2 = 1 154 MOD 2 = 0

    1 MOD 2 = 1 2 MOD 2 = 0 156578 MOD 2 = 0 48541 MOD 2 = 1 13547 MOD 2 = 1 65468 MOD 2 = 0 4897 MOD 2 = 1 1687 MOD 2 = 1
  2. 465 / 10 = 4684 / 10 = 89745 /

    10 = 7841 / 10 = 45 / 10 = 5465 / 10 = 564 / 10 = 465 / 10 = 468545 / 10 = 165547 / 10 = Actual Division (/)
  3. 125 MOD 10 = 627 MOD 10 = 438 MOD

    10 = 584 MOD 10 = 12 MOD 10 = 5 MOD 10 = 61 MOD 10 = 789851 MOD 10 = 238741 MOD 10 = 46845 MOD 10 = REMINDER Division (MOD)
  4. 15647 \ 10 = 465 \ 10 = 4851 \

    10 = 9 \ 10 = 485\ 10 = 32 \ 10 = 2115 \ 10 = 481 \ 10 = 545 \ 10 = 48 \ 10 = INTEGER Division (/)
  5. KEEPING THINGS TOGETHER Let a=5, and b = 6 then,

    compute value for each steps: s = a + b x = s + 3 m = a MOD 10 w = s \ 10 s = s + x
  6. FINDING SUM OF DIGITs --------Do these things--------- R = N

    MOD 10 S = S + R N = N \ 10 ---Repeat above things until N reaches zero----- S is our Final Answer Question: Let N = 345, we want to find sum.. i.e. 5+4+3
  7. COUNTING NO. OF DIGITs --------Do these things--------- R = N

    MOD 10 S = S + 1 N = N \ 10 ---Repeat above things until N reaches zero----- S is our Final Answer Question: Let N = 245, we want to find no. of digits.. i.e. 3
  8. CHECKING-FoR-ARMSTRONG K=N --------Do these things--------- R = N MOD 10

    S = S + R^3 N = N \ 10 ---Repeat above things until N reaches zero----- S is our Final Answer IF K=S THEN PRINT “ARMSTRONG” ELSE PRINT “NOT ARMSTRONG” Question: Let N = 345, we want to CHECK ITS ARMSTRONG property (Sum of cubed of digits is equal to original Number)
  9. FINDING HCF/GCD --------Do these things--------- C = A MOD B

    A = B B = C ---Repeat above things until C<>0 ----- A is our Final Answer Question: Let A = 42 B=,30 we want to find HCF.. i.e. 6
  10. FINDING PRODUCT OF DIGIT S = 1 --------Do these things---------

    R = N MOD 10 S = S * R N = N \ 10 ---Repeat above things until N reaches zero----- S is our Final Answer Question: Let N = 345, we want to find product.. i.e. 5*4*3
  11. FINDING REVERSE OF NUMBER --------Do these things--------- R = N

    MOD 10 S = S * 10 + R N = N \ 10 ---Repeat above things until N reaches zero----- S is our Final Answer Question: Let N = 345, we want to reverse it.. i.e. 543
  12. PALINDROME CHECK K=N --------Do these things--------- R = N MOD

    10 S = S * 10 + R N = N \ 10 ---Repeat above things until N reaches zero----- S is our Final Answer IF K=S THEN PRINT “Palindrome” ELSE PRINT “NOT Palindrome” Question: Let N = 345, we want to test if it is palindrome. (A palindrome is a number, whose reverse is equal with the original number)
  13. GENERATING PATTERNS C = 1 S = 0 --------Do these

    things--------- S = S * 10 + C PRINT S C = C + 1 ---Repeat above things until C <=5----- 1 12 123 1234 12345
  14. GENERATING PATTERNS C = 1 S = 0 --------Do these

    things--------- S = S * 10 + 1 PRINT S C = C + 1 ---Repeat above things until C <=5----- 1 11 111 1111 11111
  15. GENERATING PATTERNS S = 12345 --------Do these things--------- PRINT S

    S = S \ 10 ---Repeat above things until S <>0--- 12345 1234 123 12 1
  16. GENERATING PATTERNS S = 11111 --------Do these things--------- PRINT S

    S = S \ 10 ---Repeat above things until S <>0-- 11111 1111 111 11 1