Presentation is loading. Please wait.

Presentation is loading. Please wait.

LAB 2: REPETITION STRUCTURE #2 ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong.

Similar presentations


Presentation on theme: "LAB 2: REPETITION STRUCTURE #2 ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong."— Presentation transcript:

1 LAB 2: REPETITION STRUCTURE #2 ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong (Tum) Ms. Pattheera Panitsuk (Fon+) Mr. Pongsate Tangseng Mr. Chinorot Wangtragulsang Mr. Kanin Assantachai (Ob) 1

2 2

3 3

4 4

5 5

6 6 If (x == 1 || x == 2) if(x == 1 && x == 2) if(!x) if (x == ‘a’ || x == ‘A’)

7 7

8 8

9 9

10 Reading Pseudocode 1. Print the message asking for an integer number. printf(“Enter an integer number:”); 2. Read in the input number. scanf(“%d”,&n1); 3. Set the flag to 1. flag = 1; 4. Set the index to 2. 5. While the index is less than the input number Add one to the index for(i=2; i < n1; i++) { // 5.1.1 and 5.1.2 inside here } 10

11 Reading Pseudocode 5. While the index is less than the input number Add one to the index for(i=2; i < n1; i++) { 5.1 if the number is divisible by the index with no remainder, if(n1 % i == 0) { 5.1.1 Set the flag to 0 flag = 0; 5.1.2 Break from the loop break; } 11

12 Reading Pseudocode 6. If the flag is equal to one, if ( flag==1) { 6.1 Print the message the number is a prime. printf(“%d is a prime number”, n1); } else { 6.2 Print the message the number is not a prime. printf(“%d is not a prime number”, n1); } 12

13 To Do in Class Exercise 1, 2, 3, 4, and self practice 1 Call your TA when you finished. You may take a break Be ready for the speed test at 15.00 13

14 Exercise 1 14

15 Exercise 2 15

16 Exercise 3 16

17 Exercise 4 17

18 Self Practice 1 18

19 Speed Test Speed test should be treated just like a real exam. Rules: No talking. Be quiet. No mobile phone. No electronic devices other than your PC No Internet No cheating Cheating will result in a severe penalty TAs will not help you (except when your PC crashes). Time allowed: 45 minutes. 19

20 Speed Test Instruction Write your name on the question sheet. Create all workspace on your ‘Desktop’ When you finished Raise your hand to signal the assigned TA TA grades your work Quietly leave the room DO NOT bring the question sheet out. Leave it on your table. 20


Download ppt "LAB 2: REPETITION STRUCTURE #2 ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong."

Similar presentations


Ads by Google