Answer the question
In order to leave comments, you need to log in
Code written in C compiles but throws an error while running?
The code written in C throws an error when I enter a number into the terminal
Here is the code itself:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int monets=0;
int tf = 25;
int t = 10;
int f = 5;
int o = 1;
printf("O hai! How much change is owed?\n");
float changeFloat = get_float();
while (changeFloat<0)
{
printf("O hai! How much change is owed?\n");
changeFloat = get_float();
}
int change = changeFloat*100;
while (tf<=change) {
monets++;
}
while (t<=change) {
monets++;
}
while (f<=change) {
monets++;
}
while (o<=change) {
monets++;
}
printf("%i\n", monets);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question