What conclusion can be drawn from these two facts?
This loop for (row = 0; row <= height; row++) will generate height + 1 lines of output (0 through height inclusive)
The first output line (ie row = 0) is incorrect.
Technically,when row is 0, the spaces loop executes height times, and spaces is height + 1 when done, therefore the hashes loops executes 0 ...
Hmmm... I don't see a main() declaration anywhere.
[Edit] The problem in this question is probably the most fundamental part of learning to write a C program. You need to be able to understand how a C program is structured. In comments that have been deleted, the problem persists.
This is so basic an issue that if you can't resolve it, you really need to ...
you want to keep asking the user about height if n is smaller than 1 or larger than 8 right ? check your code, the way you're writing it ,the program is gonna keep asking for height as long as n is smaller than nine ! ( which is not what you want).
therefore the solution is change "while (n < 9)" to "while (n < 1 || n > 8)"
Time for some tough love. The logic in this code makes no sense. Take this for example:
int q = ((n / 25) % 10);
Say the amount given was $0.75. That makes n = 150. n/25 = 6. 6%10 = 6. But the actual number of quarters would be 3. I can't see how you got correct answers unless you just got lucky. I did run some tests and found some correct answers, ...
Your problem might be more logical than with just code. The pset seems to ask more how many quarters, dimes, nickels, and pennies at a minimum can you get to the exact change needed. This requires you to at least do some subtraction with n. You want to constantly subtract n with the maximum amount of cash you can subtract (25, 10, 5, or 1) without going ...
Ahh I figured it out!
Instead of using ~/pset1/hello/ $
go back to just the directory pset by using change directory
~/pset1/hello/ $ cd ~/pset1/
then add your ls command
~/pset1/ $ ls
~/pset1/ $ clang hello.c
adds the machine code to your directory and then you can execute!
My only questions now is about the hello/ . ...
4111111111111113 isn't a valid card number because it doesn't come out correctly with the Luhn algorithm. It looks like you've got the part of the problem where you check the card's company, but it doesn't look like you have the part of the problem where you check if the card is valid with the Luhn algorithm.
It looks like you're printing an extra new line at the end. You print the last newline at the end of the "row" loop, then another new line. check50 expects exact output, so try removing the last one.
Not an error, but also consider re-writing
for (R = 0; R <= row; R++)
for (int R = 0; R <= row; R++)
With the first way, the R ...
When the code is run with the test data that check50 uses, 4111111111111113, it prints INVALID twice. check50 was expecting the program to end, not to print the second INVALID.
The problem is obvious with a little testing, but I'll give you a hint. Go into the code and change every line that prints "INVALID". Add a unique number to each printf ...
if you successfully ran "make mario", why are you running clang? The make command is doing all the compiling and linking for you.
Without the correct compiler flags in the command, it won't build. Fortunately, the IDE has those set up by default.
If you're trying to "submit" the code for credit, you need to run submit50. Hopefully, you'...
First of all, "recursive" means something that calls itself repeatedly. You mean that you can't get the loop to repeat.
Think about the condition clause. while (n < 0 && n > 8); When can any number be less than 0 AND greater than 8 at the same time????? Maybe you meant to use OR instead of AND?
When you say return dollars, your program gives an output = "dollars" and ends itself.
The line of code after returning dollars is not even read. Just remove the return statement and try your code.
Have a great day.. :)
It's a simple problem and the same issue in all cases.
The code is trying to do dollar % 25 BUT, dollar is a float, not an int. The modulo operator requires both operands to be integers. Modulo cannot be applied to a float.
Maybe you meant to use owed instead? You'll need to declare owed before the do/while loop for it to stay in scope though.
If this ...
This is a very common newbie problem. The problem lies here:
int main (void);
The semicolon is breaking the code. It must be removed. The correct form is this:
int main (void)
That semicolon marks the line as a function signature. When you get to functions, you'll understand this more. ;-)
If this answers your question, please ...
This is a good question. There is merit to moving on and to finishing everything before moving on.
These classes are designed to build on everything that comes before. Moving on before mastering a concept can make learning and applying new concepts more difficult because you're fighting with multiple concepts at the same time.
However, banging your head ...
The problem is in your nested for loop. It prints a space all the way up until i + j <= n - 1. Once this is no longer true, your program exits the loop.
Let's look at this in a little more detail:
If n = 7 and i = 0, the if statement in the nested loop will continue printing spaces until i + j > n - 1, meaning when j = 7. As soon as that happens, ...
ok so when you are doing this -> " int t = n % 100000000000000/1000000000000;" The '/' sign is dividing your 1000000000.. by 1000000... I think you meant to use '/' sign as a symbol for 'or'. The resultant x or y are not single digits.
Besides you are making this code unnecessarily long and complicated. i would suggest you to go through the ...
First, it's typically easier for people to help you if you copy/paste your code (or just the relevant parts of your code), so they can try running your code.
But go through what happens if i = 7, and multiplied_digits = 0 on line 27. i * 2 = 14, so you should end up with multiplied_digits = 5.
if((i * 2) > 9) // this is true, because (i * 2) is 14
Sign out of the ide with this link: http://ide.cs50.io and close the tab/window.
Next, sign completely out of github.
Next, open a new tab/window and go to http://ide.cs50.io You should be prompted to sign in. Do so.
Now try check50 again.
If you still get that error, send an email to email@example.com with your problem & details.
The problem is simple. You have to switch to the same directory as the hello.c file. THEN, you can run make hello.
Looking at the image, the hello.c file is in the ~/pset1 directory but you're trying to run make in it's parent directory, ~/.
just run this cd pset1
If this answers your question, please click on the check mark to accept. Let's keep up on ...
EEK: The dreaded goto statement!!
It's almost always a bad practice to use a goto statement and should be avoided whenever possible!!!!
The next bad practice is encapsulating the bulk of a program in an if or else condition.
When checking or validating input like this, one should always do that and only that in a localized code block.
In this case, you ...
The issue seems to be you're printing the float variable c as the final input. You seem to only use that variable to get the money owed amount and nothing else.
The variable that stores the answer to the problem is coins.
This is a scope problem, the variable "change" declared in main is visible in the whole main program, but when declaring change in the DO-WHILE loop, this second variable is different from the first change that is shaded by this second. The reason is the rules of scope of a variable, you must have these clear rules, in general the variables ...
The code is supposed to keep prompting for a new value until the user enters an acceptable number. This code doesn't do that. Instead, it will ask for a number, and if that number is out of range, it will skip down to the end of the program where it will ask for a new number a second time, but it won't do anything with it. When the second number is ...