Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <cs50.h>
#include <stdio.h>
#include <math.h>

int get_num(void);
int main(void)
{
//assign variable for the number of coins

int value = get_num(); //get input for value
printf("%i\n", value);
// for loops to determine how many of each cent needed for the value input
int count = 0;
for (int q = 1; value >= 25; q++)
{
value -= 25; // keep subtracting until value is less than 0.25
count++; //+1 to count everytime when subtracted
}
for (int d = 1; value >= 10; d++)
{
value -= 10;
count++;
}
for (int n = 1; value >= 5; n++)
{
value -= 5;
count++;
}
for (int p = 1; value >= 1; p++)
{
value -= 1;
count++;
}
printf("%i coins\n", count); //print count for user
}

int get_num(void)
{
float num;
do
{
num = round((get_float("Change owed: \n")) * 100);
}
while (num < 0);
return num;
}
Binary file added dodge and catch .sb3
Binary file not shown.
8 changes: 8 additions & 0 deletions hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cs50.h>
#include <stdio.h>

int main(void)
{
string name = get_string("What is your name?\n");
printf("hello, %s\n", name);
}
31 changes: 31 additions & 0 deletions mario.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <cs50.h>
#include <stdio.h>

int get_num(void); // get input function
int main(void) //main function
{
int height = get_num(); // get input from get_num function
for (int i = 1; i < height + 1; i++) // for loop
{
for (int s = 0; s < height - 1 - i + 1; s++)// for loop
{
printf(" "); //print space
}
for (int n = 0; n < i; n++)// for loop
{
printf("#"); // print hash
}
printf("\n"); // go to the new line
}
}
int get_num(void) //getting an integer from this function
{
int num;//garbage value
do
{
num = get_int("Height: ");//get input for num
}
while (num < 1 || num > 8);//while num is less than 1 or greater than 8
return num; // return to num for input
}