Questions tagged [round]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
92 views

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 ...
user avatar
0 votes
1 answer
356 views

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 ...
user avatar
0 votes
2 answers
45 views

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",...
user avatar
3 votes
1 answer
532 views

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 ...
user avatar
  • 35
1 vote
1 answer
189 views

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 ...
user avatar
0 votes
1 answer
148 views

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) { $ = ...
user avatar
0 votes
1 answer
151 views

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 ...
user avatar
0 votes
1 answer
328 views

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 ...
user avatar
  • 144
0 votes
2 answers
148 views

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 ...
user avatar
  • 65
1 vote
2 answers
134 views

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 ...
user avatar
0 votes
1 answer
188 views

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 ...
user avatar
  • 1
0 votes
1 answer
446 views

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

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 ...
user avatar
  • 79
0 votes
0 answers
171 views

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 ? ...
user avatar
0 votes
1 answer
2k views

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 ...
user avatar
0 votes
2 answers
1k views

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 ...
user avatar
0 votes
2 answers
227 views

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 ...
user avatar
1 vote
2 answers
645 views

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 ...
user avatar
0 votes
1 answer
611 views

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 ...
user avatar
0 votes
2 answers
428 views

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' ...
user avatar
  • 50