83 lines
No EOL
2.2 KiB
C
83 lines
No EOL
2.2 KiB
C
// header files
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
// constants
|
|
|
|
/*
|
|
Name: add_two_nums
|
|
Process: adds two numbers together given user input
|
|
Function input/parameters: NONE
|
|
Function output/parameters: NONE
|
|
Function output/returned: NONE
|
|
Device input/---: NONE
|
|
Device output/---: NONE
|
|
Dependencies: included by standard libraries
|
|
*/
|
|
int add_two_nums()
|
|
{
|
|
// define variables
|
|
int first_num, second_num, total;
|
|
// get user input
|
|
printf("---Adding two numbers---\nPlease enter two numbers(space in between): ");
|
|
scanf("%d %d", &first_num, &second_num);
|
|
// do calculations
|
|
total = first_num + second_num;
|
|
// display results
|
|
printf("\n%d + %d = %d!", first_num, second_num, total);
|
|
// return success
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
Name: add_two_nums_parameterized
|
|
Process: adds two numbers together given user input as parameters
|
|
Function input/parameters:
|
|
Function output/parameters: NONE
|
|
Function output/returned: NONE
|
|
Device input/---: NONE
|
|
Device output/---: NONE
|
|
Dependencies: included by standard libraries
|
|
*/
|
|
int add_two_nums_parameterized(int first_num, int second_num)
|
|
{
|
|
// define variables
|
|
int total;
|
|
// get user input
|
|
printf("---Adding two numbers PARAMETERIZED!---\n");
|
|
// do calculations
|
|
total = first_num + second_num;
|
|
// display results
|
|
printf("\n%d + %d = %d!", first_num, second_num, total);
|
|
// return total
|
|
return total;
|
|
}
|
|
|
|
/*
|
|
Name: main
|
|
Process: Runs all the functions listed above that was used as preparation for
|
|
CS480. Videos were used as the similar practice.
|
|
Function input/parameters: NONE
|
|
Function output/parameters: NONE
|
|
Function output/returned: NONE
|
|
Device input/---: NONE
|
|
Device output/---: NONE
|
|
Dependencies: included by standard libraries
|
|
*/
|
|
int main()
|
|
{
|
|
// define/initialize variables
|
|
int tnNum1, tnNum2, tnSum;
|
|
// get user input
|
|
printf("Please input numbers for the parameterized version of adding two numbers.\n");
|
|
scanf("%d", &tnNum1);
|
|
scanf("%d", &tnNum2);
|
|
// do calculations
|
|
add_two_nums();
|
|
tnSum = add_two_nums_parameterized(tnNum1, tnNum2);
|
|
// display results
|
|
// return success
|
|
return 0;
|
|
} |