DE LA SALLE UNIVERSITY GOKONGWEI COLLEGE OF ENGINEERING SY 2018-2019, TERM 2
COMPUTER FUNDAMENTALS PROGRAMMING 2 EXPERIMENT 7 FUNCTION
NAME: Xavier Lancelot A. Veloso STUDENT ID NUMBER: 11516577 STUDENT E-MAIL ADD:
[email protected] STUDENT CONTACT NO: 09456079156 COURSE CODE: CIV-TRE SECTION: EQ SCHEDULE: W 2:30pm-5:30pm INSTRUCTOR: ANA ANTONIETTE C. ILLAHI
GRADING RUBRICS: ACTIVITY OUTPUT (40%): OBSERVATION AND CONCLUSION (20%): ASSESSMENT (40%): TOTAL:
STUDENT SIGNATURE: _______________ DATE SUBMITTED: March 15, 2019
Function Activity 1 a. Problem Write a C program that will output Hello World! Using a function. b. Algorithm -Process: The program will multiply the # (j++, j=0) above and below the hello world text. -Output: Display Hello World (hello( )) c. Flowchart START
Process: The program will multiply the # (j++, j=0) above and below the hello world text
Output: Display Hello World (hello ( ) )
END
Figure 1. String Activity 1 Flowchart The program not need an input from the user. The program will process the hello world and the # will be multiplied by the amount programmed by the programmer. The output will be Hello world in the middle of two lines of #.
d. Source Code
e. Program Output
Function Activity 2 a. Problem Write a C program that will display Hello World using different functions. b. Algorithm -Process: The program will get the designs used in Hello World and multiply them (void starline(char = ‘#’, int=30)
-Output: The program will display Hello World with $ and @ (void starline (char ch, int n) c. Flowchart START
Process: The program will get the designs used in Hello World and multiply them (void starline(char = ‘#’, int=30)
Output: The program will display Hello World with $ and @ (void starline (char ch, int n)
END
Figure 2. Function Activity 2 Flowchart The program will not require the user to input anything. The program, once opened, will make @ and # loop until a certain amount of times. The program will output hello world and @ and # above and below the hello world text.
d. Source Code
e. Program Output
Function Activity 3 a. Problem Write a C program that will display the values inputted by the user. b. Algorithm -Input: Enter three numbers ((int &t)) -Process: The program will process the inputted values in to the output. (abc (temp, x, w)) -Output: Display the the three values (
c. Flowchart START
Process: The program will count the number of characters (strlen1(str1)m (strlen2(str2))
Output: Display the number of characters (length, length2)
END
Figure 3. Function Activity 3 Flowchart The program will not require any input by the user. The program will start counting the characters given by the programmer. The output will display the amount of characters given by the programmer. (<
d. Source Code
e. Program Output
Function Supplementary 1 I.
Supplementary a. Problem Write a C++ program that will find the sum, difference, product and quotient of two inputted values using function. b. Algorithm -Input: Enter two values (int num, int num2) -Process: Create a formula function for each formula needed. (int sum, int dif, int pro, int quo) Direct the inputted values to each of the formula function (a=x+y,a=xy,a=x*y,a=x/y) -Output: Displays the sum, difference product and quotient (<<e<<) Flowchart START
Input: Enter two values (num, num2)
Process: Create a formula function for each formula needed. (int sum, int dif, int pro, int quo)
Process: Direct the inputted values to each of the formula function (a=x+y,a=x-y,a=x*y,a=x/y)s:
Output: : Displays the sum, difference product and quotient (<<e<<)or even and the sum of all odd integers. (sum)
END
Figure 4. Function Supplementary 1 Flowchart The activity requires the user to input two numbers to be used in formulas. The program will give the 4 formulas the inputted values for the function to find the solution independently. Once the functions are done computing, the output will display the sum, difference, product and quotient from the formula functions.
c. Source Code
d. Program Output
II.
PROGRAM OBSERVATION AND CONCLUSION The program is a function program that is useful for finding the addition, difference, product and quotient of a number. The use of a function is useful for having a neat and structured line of codes. With functions, it is easier to edit than not using functions. The program can be used for basic math or as a basic calculator.