Skip to main content

Questions tagged [round]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer

How should rounding be handled in pset6 readability?

I'm struggling to understand what sort of rounding needs to be implemented to produce the grade in [pset6 readability][1]. For the Harry Potter extract provided ("Harry Potter was a highly ...
Eystein Thanisch's user avatar
0 votes
1 answer

Readability in C passes tests on instructions page but when submitting, only 2/11 pass

I've written all of my code and tested that the letter, sentence and word output is counting correctly, which it seems to be. I even tested with all of the sentences on the instructions page and that ...
JackJack's user avatar
0 votes
2 answers

PS1, Cash Question. Error when printing results of roundI() function

I am trying to print out the results of the round() function. #include <stdio.h> #include <math.h> int main(void){ float change = 4.2; //want change for $4.2 printf("rounded %i",...
monkey king's user avatar
3 votes
1 answer

Pset2 - Readability: How to round a .5 number depending on the 2nd digit after the decimal point

I have written a solution for readability from pset2 but I'm having problems with one of the points: :( handles single sentence with multiple words expected "Grade 7\n", not "Grade 8\n". So I ...
Ada's user avatar
  • 35
1 vote
1 answer

PSet1 Cash returning implicitly declaring library function 'roundf' with type 'float (float)'

I am currently working on the pset1 greedy (cash) project. I am so close to finishing and I only have one more thing to complete before I can submit it as correct. I am working on rounding the initial ...
Jacob Pieczynski's user avatar
0 votes
1 answer

Pset1 Cash - Trying to round float value DURING computation and not after

My original code for this problem is as follows: int main(void) { float c = 0; //total coins float $ = get_float("Change: "); while($ <= 0.0099999 && $ >= 0.00000001) { $ = ...
alienanteater's user avatar
0 votes
1 answer

Could someone explain the significance of double round in pset1 "greedy" (less comfortable)?

I've wrote the following which passes check50 and operates as intended: #include <stdio.h> #include <cs50.h> #include <math.h> ... int cents = round(change * 100); ... I've ...
AvidUrner's user avatar
0 votes
1 answer

Number imprecision & Rounding - C$50 Finance

I am implementing my databases & functions for C$50 finance, but am running into some problems in terms of rounding. After certain stocks are bought, or a bad number w/ multiplication, I get ...
Davis's user avatar
  • 144
0 votes
2 answers

pset1 greedy, help pleeeease

I have just run check50 and well the main part of my code is not working and I'm thinking it's because I'm not using the round function correctly. Please help. Here's my code (ignore the constant ...
Sofia's user avatar
  • 65
1 vote
2 answers

Pset1 Greedy Help Please

I think my way of solving Greedy is a little unorthodox, but let's leave that for another day. If i'm looking for an answer to $2.11 , it will output 8Q,1D,no nickels and pennies. I am assuming it is ...
coldeskimo03's user avatar
0 votes
1 answer

Compilation error on function round in greedy.c, pset1

During compilation I have this error message. $ clang greedy.c /tmp/greedy-e7d5e2.o: In function main': greedy.c:(.text+0x5c): undefined reference toround' clang: error: linker command failed with ...
Pavan's user avatar
  • 1
0 votes
1 answer

Still Need Help. Pset1 Geedy with round()

I am still having trouble understanding what I'm doing wrong. I know the key has to do with how I use the round function and how I convert in order to avoid float imprecision (e.g. .01 is actually ....
Emeka A's user avatar
1 vote
1 answer

Why should I use round in greedy?

I am reading the manual (type 'man round' in the terminator) of round for Greedy and I don't understand exactly why I should use round. I see it is rounding up a float to a integer. But I don't want ...
Kiwi's user avatar
  • 179
0 votes
0 answers

How to link math.h using " make "? [duplicate]

In greedy , for using "round" function , I need the compiler to automatically include math.h every time ( without linking it every time )using make but not with gcc . Is it possible ? if so , How ? ...
Sai Charan Nivarthi's user avatar
0 votes
1 answer

Difficulty rounding on Greedy in pset1

I'm currently working on Greedy from problem set 1. When I run the CS50 check, everything works correctly except when with an input of 4.2. I know that this is related to how the float isn't rounded ...
Rachel Misbin's user avatar
0 votes
2 answers

Modulo not working in Greedy

I'm working on pset1 Greedy and am trying to use a modulo to eliminate the need for loops. The user inputs a float in the form of the "change" needed. This is converted into a whole number for easier ...
John Jr's user avatar
0 votes
2 answers

Pset1 greedy.c program error

I faced a problem when executing greedy.c. I think every thing is correct (or probably not), but every time I put $4.2 as the input the program outputs 22 coins, which should be 18 ( 16 x 25c + 2 x ...
XT Tony's user avatar
1 vote
2 answers

pset1 greedy rounding

I used n = 100.0*n; float roundf(float n); to covert dollar to cent and round it. However when I use gdb with an input of 4.2, the converted n is 419.999... and the program yields a result of 22 ...
eifphysics's user avatar
0 votes
1 answer

Getting a inifinite do while loop while using printf() and round()

This is part of code from my greedy.c The purpose of this do while loop is to get a valid input. I'm having trouble, I tested it outside do while loop and it was working fine. I think that ...
Valentino Skobljanec's user avatar
0 votes
2 answers

roundf function gives error in clang but runs smoothly in g++

while(a<0) { printf("\n O hai! How much change is owed?"); scanf("%f",&a); } b=(int)roundf(float(a*100)); The above is a part of my code. Clang gives an error 'expected expression' ...
Amrita's user avatar
  • 50