Good Stopping point for CS480 Prep
++ Phases 1-6 Preparation ++ C, H, Makefiles
This commit is contained in:
parent
b861b15368
commit
ca321e6c4e
19 changed files with 889 additions and 0 deletions
83
Preparation/CS480_Prep.c
Normal file
83
Preparation/CS480_Prep.c
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
// 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue