2

Happy to help. You're running into syntax errors, which you'll have a lot of as you're getting started. Always best to cure them in order because sometimes the early ones cause a lot of later ones. I think the reason you're not finding the first one is that it's one of those deceptive ones where the problem isn't on the line where it's being signaled. ...


2

Right before bool sorted = false;, you have return true;. You give a return value before anything else happens, so your function does exactly that: it returns that value and stops executing any further code.


1

This loop will run exactly once every time. Look at your test. It has to be true for the loop to execute more than once, but that will never happen. What number can be less than zero AND greater than 23 AT THE SAME TIME? ;-) If this answers your question, please click on the check to accept. Let's keep up on forum housekeeping. ;-)


1

My bet is that when you tried to run it, it just sat there, looking like it is doing nothing. Actually, this is an infinite loop. It's running the loop thousands to millions of times over, depending on how long you let it run. Want proof? Add two lines of code: int count = 0; //creates and initializes a counter do { result=a+b; ...


1

You can check divisibility like this div = result % 7; And I think you need to use integer instead float #include <stdio.h> #include <stdlib.h> int main(void) { int a, b, result; a = 2; b = 3; do { result = a + b; } while ((result % 7) != 0); printf("%f\n", result); return(0); }


1

The message is clear, you must learn to interpret it as a programmer since it is almost impossible to write a program free of errors at the first attempt. If you look at the first time that the variable n is declared is not initialized, the solution is simple and your program should be like this: int main(void) { int n = 0; do { n = ...


1

By this you declared (but did not initialize) the variable: int n; The following is recognized as a comment but not an initialization because of "//": // n = get_int("Please type in an integer here: "); So you can simply delete "//" and after that the variable will be initialized: n = get_int("Please type in an integer here: ");


1

what you are seeing is a side effect of how get_int works. If you have something like: int num; do { printf("Number: "); num = get_int(); } while (num < 0); And run it, you will see this behavior: Number: -1 Number: foo Retry 2 But if you change your do while to this: do { num = get_int("Number: "); } while num < 0; Then you will ...


1

Well, let's think about what's happening. The code is changeOwed = get_float(); which is supposed to get a float and store it in changeOwed. However, changeOwed is declared as an int, not a float, so the number returned from get_float() is cast as an int. In the process of casting a float as an int, the decimal or fractional part is truncated, not ...


1

Your while loop does not end up EDIT: (Thanks to SuperNovaCoder for your intervention) The problem is that equality must be achieved ie the conditions must be >= EDIT1: while(cent_amount>=0) should be: while(cent_amount>0) To allow the loop to finish


1

This conditional just says that if a height of 0 is entered, which is a requirement of the spec, the program ends by returning 0. If you want to print a pyramid of height 0, you don't actually need to print anything!


1

Your code is actually doing what you told it to, but you told it to print out the number of bottles before it exited the for-loop. A simple fix is to put the printf outside the for-loop. If you still have issues/questions, comment below.


1

You lack the main function, all console programs must have a main function: int main(void) { some code } The error is surely because the compiler thinks that you are going to define or declare a function, the do-while loop is the most appropriate for this case. EDIT All statements must end in semicolons (;) int minutes = get_int() should be: int ...


1

Looks like your are trying to write fwrite(&buffer, sizeof(buffer), 1, dest); before dest is defined. How so? Let's assume the first read does not find a jpeg signature. What then? It enters the do/while loop, and tries to write to dest, which is undefined. Make sure you are using the CS50x 2016 version of the specification, in which the jpeg signature ...


Only top voted, non community-wiki answers of a minimum length are eligible