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 ...
Peter's user avatar
  • 1,412
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 ...
Cliff B's user avatar
  • 68.8k
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; ...
Pavel's 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 ...
MARS's user avatar
  • 5,169
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 ...
Olga's 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 ...
curiouskiwi's user avatar
  • 18.7k
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, ...
Cliff B's user avatar
  • 68.8k
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) ...
MARS's user avatar
  • 5,169
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 ...
Steve Bunting's 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 ...
SuperNovaCoder's 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 ...
MARS's user avatar
  • 5,169
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 ...
DinoCoderSaurus's user avatar

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