Revision 1 Nouf almunyif Pseudocode Flowcharts 2 Nouf
- Slides: 35
Revision 1 Nouf almunyif
Pseudocode & Flowcharts 2 Nouf almunyif
Example 1 3 �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
Solution 4 � 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
Solution 5 Start Read amount no yes Amount > 1000 Zakat =0. Zakat =(2. 5/100)*amount Print Zakat Nouf almunyif End
Example 2 6 �Draw a flowchart to find the sum of first 50 natural numbers. � 1+2+3+ …. . +50 Nouf almunyif
Nouf almunyif 7
Structure of a. c file 8 Nouf almunyif
Nouf almunyif 9
input/output 10 Nouf almunyif
Output: If you need to display a string on the screen 11 Nouf almunyif
Input: if you want to read values from the user 12 Nouf almunyif
Data types 13 Nouf almunyif
Declaring different types 14 Nouf almunyif
output 15 Nouf almunyif
Constants 16 Nouf almunyif
Operator precedence 17 Nouf almunyif
Branching if syntax 18 Nouf almunyif
Example 19 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
Branching if syntax 22 if (test. Expression 1) { // statements to be executed if test. Expression 1 is true } else if(test. Expression 2) { // statements to be executed if test. Expression 1 is false // and test. Expression 2 is true } else if (test. Expression 3) { // statements to be executed if test. Expression 1 //and test. Expression 2 is false and test. Expression 3 is true }. . else { // statements to be executed if all test expressions are false } Nouf almunyif
example 23 Nouf almunyif
24 Nouf almunyif
what will be printed if x=5 y=8 25 Nouf almunyif
26 Nouf almunyif
Modify the previous code to produce the output shown. 27 Nouf almunyif
28 Nouf almunyif
29 Nouf almunyif
30 Nouf almunyif
Conditional operator ? : 31 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
Conditional operator ? : if condition is true ? then X return value : otherwise Y value; 32 Nouf almunyif
switch. . . case Statement Syntax 33 switch (n) { case constant 1: // code to be executed if n is equal to constant 1; break; case constant 2: // code to be executed if n is equal to constant 2; break; . . . default: // code to be executed if n doesn't match any constant } Nouf almunyif
34 Nouf almunyif
35 Nouf almunyif
- Nifif
- Hierarchy in a pseudocode
- 3-3 assignment: introduction to pseudocode and flowcharts
- Flowcharts and pseudocode
- Pseudocode adalah
- Algorithms and flowcharts
- Xkcd flowchart
- Passive sentence
- Flo the hedgehog
- Qms nouf
- Expressing algorithm
- Apriori pseudocode
- Pseudocode for loop
- Bjarne stroustrup
- Pseudocode standard
- Pseudocode outline
- Topological sort pseudocode
- Pseudocode adalah
- Array flowchart
- Pseudocode for brushing teeth
- Dfs pseudocode
- Sort 6
- Pseudocode examples
- Pseudocode merge sort
- Pseudocode switch case
- Pseudocode for brushing your teeth
- метод зейделя
- Nested loop in c
- Pseudocode for making a cup of tea
- Basic computer operations in pseudo-code
- Pseudocode
- Pseudocode flowchart
- Contoh flowchart menu utama
- Pseudocode problem solving examples
- Pesudocode
- Sequence pseudocode