forgot to commit this

This commit is contained in:
SowinskiBraeden committed 2025-10-26 12:51:57 -07:00
1 parent 6a53c86e8f
commit f63842d487
14 files changed
+353 -20

No files matched your search

+20 -1
View File
@@ -1,8 +1,27 @@
#include <stdio.h>
/*
* Course: COMP 2510
* Assignment: Assignment 1
* Name: Braeden Sowinski
* Student ID: A01385066
* Date: 2025-09-20
* Description: Calculate download speeds from
* given file size and download speed
*/
#define MEGABYTES_TO_MEGABITS 8
int main(void) {
/**
* main program entry
*
* takes in user input for download speed
* int Mbs and file size in MBs
* and calculates the download speed
*/
int main(void)
{
float downloadSpeedMbs;
float fileSizeMB;
float downloadTimeSeconds;
+31 -6
View File
@@ -1,26 +1,51 @@
#include <stdio.h>
/*
* Course: COMP 2510
* Assignment: Assignment 1
* Name: Braeden Sowinski
* Student ID: A01385066
* Date: 2025-09-20
* Description: Convert centimeters to feet and inches
*/
#define CENTIMETERS_PER_FOOT 30.48
#define CENTIMETERS_PER_INCH 2.54
#define INCHES_PER_FOOT 12
int main(void) {
/**
* main program entry
*
* continuously takes user input for a height
* in centimeters and then converts that to
* feet and inches with proper amount of decimal
* points.
*
* Quits when a number less than or equal to 0
* is inputed.
*/
int main(void)
{
float heightCm;
int heightFeet;
float heightInches;
do {
do
{
printf("Enter a height in centimeters (<=0 to quit): ");
scanf("%f", &heightCm);
if (heightCm <= 0) {
if (heightCm <= 0)
{
break;
}
heightFeet = (heightCm / CENTIMETERS_PER_FOOT);
heightInches = (heightCm / CENTIMETERS_PER_INCH) -
heightInches = (heightCm / CENTIMETERS_PER_INCH) -
(INCHES_PER_FOOT * heightFeet);
printf(
@@ -35,4 +60,4 @@ int main(void) {
printf("Bye\n");
return 0;
}
}
+28 -5
View File
@@ -1,23 +1,46 @@
#include <stdio.h>
int main(void) {
/*
* Course: COMP 2510
* Assignment: Assignment 1
* Name: Braeden Sowinski
* Student ID: A01385066
* Date: 2025-09-20
* Description: Calculate sum of squares from X to Y
*/
/**
* main program entry
*
* takes in user input for an upper and lower
* limit, then calculates the sum of squares
* from the lower to the upper limit.
*
* continuously takes input until upper limit
* is less than or equal to lower limit
*/
int main(void)
{
int max;
int min;
int sumOfSquares;
do {
do
{
sumOfSquares = 0;
printf("Enter a lower and upper limit: ");
scanf("%d %d", &min, &max);
if (max <= min) {
if (max <= min)
{
break;
}
for (int i = min; i <= max; i++) {
for (int i = min; i <= max; i++)
{
sumOfSquares += i * i;
}
@@ -33,4 +56,4 @@ int main(void) {
printf("Done\n");
return 0;
}
}
+35 -7
View File
@@ -1,40 +1,66 @@
#include <stdio.h>
/*
* Course: COMP 2510
* Assignment: Assignment 1
* Name: Braeden Sowinski
* Student ID: A01385066
* Date: 2025-09-20
* Description: Demonstrate how to copy arrays using different methods
*/
#define ARRAY_SIZE 5
void printArray(double arr[]) {
for (int i = 0; i < 5; i++) {
/**
* printArray to validate copy
*/
void printArray(char arrName[], double arr[]) {
printf("\n%s\n", arrName);
for (int i = 0; i < 5; i++) {
printf("%.1f, ", arr[i]);
}
printf("\n");
}
/**
* copy_arr using array notatoin
*/
void copy_arr(double target[], double source[], int size) {
for (int i = 0; i < size; i++) {
target[i] = source[i];
}
printArray(target);
printArray("target 1:", target);
}
/**
* copy_ptr copies an array using pointer arithmatic
*/
void copy_ptr(double *target, double *source, int size) {
for (int i = 0; i < size; i++) {
*(target + i) = *(source + i);
}
printArray(target);
printArray("target 2:", target);
}
/**
* copy_ptrs copies an array using pointers
*/
void copy_ptrs(double *target, double *source, double *lastElement) {
while (source <= lastElement) {
target = source;
source++;
target++;
}
printArray(target);
printArray("target 3:", target);
}
/**
* main program entry to test different ways
* of copying arrays
*/
int main(void) {
double source[ARRAY_SIZE] = {1.1, 2.2, 3.3, 4.4, 5.5};
@@ -42,9 +68,11 @@ int main(void) {
double target2[ARRAY_SIZE];
double target3[ARRAY_SIZE];
printArray("source:", source);
copy_arr(target1, source, ARRAY_SIZE);
copy_ptr(target2, source, ARRAY_SIZE);
copy_ptrs(target3, source, source + ARRAY_SIZE);
return 0;
}
}