Presentation is loading. Please wait.

Presentation is loading. Please wait.

INC 161 , CPE 100 Computer Programming

Similar presentations


Presentation on theme: "INC 161 , CPE 100 Computer Programming"— Presentation transcript:

1 INC 161 , CPE 100 Computer Programming
Lab 11

2 Task 1 #include <stdio.h> // Write you function here main() { int i = 2; increase(&i); printf(“i = %d”,i); } From the code given, write a function so that the program +2 and print i = 4. You must not change anything in main().

3 Task 2 #include <stdio.h> // Write you function here main() { int i = 2; i = increase(i); printf(“i = %d”,i); } From the code given, write a function so that the program +2 and print i = 4. You must not change anything in main().

4 Task 3 #include <stdio.h> // Write you function here main() { int a = 12, b = 16, c = 20, d; hcf(a,b,c,&d); printf(“HCF = %d”,d); } From the code given, write a function so that the program calculate the highest common factor (ห.ร.ม.) of a,b,c and get the result to d . You can assume that a,b,c are less than 1000

5 Write a flowchart first.
e.g. a,b,c = 2,4,8 Assume start from 10 (for short) 2,4,8 is divisible by 10 – no 2,4,8 is divisible by 9 - no 2,4,8 is divisible by 8 - no 2,4,8 is divisible by 7 - no 2,4,8 is divisible by 6 - no 2,4,8 is divisible by 5 - no 2,4,8 is divisible by 4 - no 2,4,8 is divisible by 3 - no 2,4,8 is divisible by 2 – yes - >stop

6 Task 4 #include <stdio.h> // Write you function here main() { int a = 12, b = 16, c = 20, d; d = hcf(a,b,c); printf(“HCF = %d”,d); } From the code given, write a function so that the program calculate the highest common factor (ห.ร.ม.) of a,b,c and get the result to d . You can assume that a,b,c are less than 1000


Download ppt "INC 161 , CPE 100 Computer Programming"

Similar presentations


Ads by Google