1 / 35

Zakat Calculator - Calculate zakat based on user input

This program calculates zakat based on the user-entered amount, where zakat is equal to 2.5% of the amount. If the amount is less than 1000, zakat is not calculated.

Download Presentation

Zakat Calculator - Calculate zakat based on user input

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Revision Nouf almunyif

  2. Pseudocode & Flowcharts Nouf almunyif

  3. Example 1 • Draw a flowchart for a program that calculates the Zakat, where the user enter the amount of money then the program show the zakat. • Zakat =(2.5/100) * amount. • Zakat is not calculated if the amount is less than 1000 S.R Nouf almunyif

  4. Solution • Input • amount. • Processing • Check if amount is below 1000  Zakat =0. • Check if amount is above 1000 Zakat =(2.5/100) * amount • Output • Zakat Nouf almunyif

  5. Solution Start Read amount yes Amount > 1000 no Zakat=0. Zakat=(2.5/100)*amount Print Zakat End Nouf almunyif

  6. Example 2 Draw a flowchart to find the sum of first 50 natural numbers. 1+2+3+ ….. +50 Nouf almunyif

  7. Nouf almunyif

  8. Structure of a .c file Nouf almunyif

  9. Nouf almunyif

  10. input/output Nouf almunyif

  11. Output: If you need to display a string on the screen Nouf almunyif

  12. Input: if you want to read values from the user Nouf almunyif

  13. Data types Nouf almunyif

  14. Declaring different types Nouf almunyif

  15. output Nouf almunyif

  16. Constants Nouf almunyif

  17. Operator precedence Nouf almunyif

  18. Branchingif syntax Nouf almunyif

  19. Example • Write a code that read x and change its value as follows: • If x is even, divide x by 2. • If x is odd, multiply x by 3 and subtract 1. Nouf almunyif

  20. Nouf almunyif

  21. Nouf almunyif

  22. Branchingif syntax if (testExpression1) { // statements to be executed if testExpression1 is true } else if(testExpression2) { // statements to be executed if testExpression1 is false // and testExpression2 is true } else if (testExpression 3) { // statements to be executed if testExpression1 //and testExpression2 is false and testExpression3 is true } . . else { // statements to be executed if all test expressions are false } Nouf almunyif

  23. example Nouf almunyif

  24. Nouf almunyif

  25. what will be printed if x=5 y=8 Nouf almunyif

  26. Nouf almunyif

  27. Modify the previous code to produce the output shown. Nouf almunyif

  28. Nouf almunyif

  29. Nouf almunyif

  30. Nouf almunyif

  31. Conditional operator ?: if condition is true ? then X return value : otherwise Y value; Exercise: Write a code that test whether an integer variable score contains a valid test score. Valid test scores are in the range from 0 to 100. Nouf almunyif

  32. Conditional operator ?:if condition is true ? then X return value : otherwise Y value; Nouf almunyif

  33. switch...case StatementSyntax • switch (n) • ​{ • case constant1: • // code to be executed if n is equal to constant1; • break; • case constant2: • // code to be executed if n is equal to constant2; • break; • . . . • default: • // code to be executed if n doesn't match any constant • } Nouf almunyif

  34. Nouf almunyif

  35. Nouf almunyif

More Related