2 votes

pset1 "expected identifier error in do-while loop

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. ...
user avatar
  • 64.1k
2 votes
Accepted

Do While loop not executing for pset3

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 ...
user avatar
  • 1,424
1 vote
Accepted

do while loop not looping

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 ...
user avatar
  • 64.1k
1 vote

do a+b while its not divisible by c

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 ...
user avatar
  • 64.1k
1 vote

do a+b while its not divisible by c

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; ...
user avatar
  • 11
1 vote

Problems on mario (pset1)

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 ...
user avatar
  • 5,172
1 vote
Accepted

Problems on mario (pset1)

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 ...
user avatar
  • 28
1 vote
Accepted

Pset1 Water Issue, reprompting with "Retry: " for Non-integers, and "Minutes: " for negative integers

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 ...
user avatar
  • 18.4k
1 vote
Accepted

Greedy - Do While Negative Float

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, ...
user avatar
  • 64.1k
1 vote

Pset1 Greedy; problem with do-while loop

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) ...
user avatar
  • 5,172
1 vote
Accepted

PSET1 mario.c why if and return

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 ...
user avatar
1 vote
Accepted

Do-while loop in pset1 returning negatives

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 ...
user avatar
1 vote

Can't get the do-while loop to work in pset1

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 ...
user avatar
  • 5,172
1 vote
Accepted

PSET 4 recover.c - segmentation fault, do while loop

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 ...
user avatar

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