You need to run the calculation of the grade for all k < 20. And here is working code for what you want. Please make sure you understand what it is doing and feel free to ask if you don't. Notice...
Type: Posts; User: askinne2
You need to run the calculation of the grade for all k < 20. And here is working code for what you want. Please make sure you understand what it is doing and feel free to ask if you don't. Notice...
Thanks, I can't believe I didn't put that inside the loops. Anyways, it's still coming up with the wrong answer. It comes up with a long list of answers that don't fit the Pythagorean theorem. Like...
I am solving the euler probelm (no. 9) that wants to find the only Pythagorean triplet such that a+b+c = 1000. Does anyone see what is wrong with my code? It looks like it should work to me...
...
I didn't realize that Euler's problem was to find the 10,001st prime and not the 1,001st prime, lol. That is the 1,001st prime number. Thanks again
I just was trying to make a simple program that did what it had to do, and then I will go and try to make it efficient.
Thanks KBriggs. That works perfectly :)
Did you look up 2 dimensional arrays? Try to write the program using one.
Yeah, Adak's solution is your best option. I had to do it before. You can just write a function (call it intCast or something like that) that will add .5 to the number and then type cast to the int.
I forgot to post the code where I corrected that. Anyways, my answer isn't coming out correct still. Anyone know what's wrong with this code for finding the 1001st prime number?
#include...
Woops, sorry. I didn't notice that I guess. To be honest, I don't know why it is getting 3 with the type cast. When a solution is posted I will be sure to take note :)
Woops - didn't know I was speaking with the OP himself, haha. Well there is fgets(); if you want to use that.
I found your problem. You can't just say take it to the 1/3 power. You need to make 1/3 into a double type and then take it to that power. Here is some working code for you...
int main()
{
...
It must not be evaluating to exactly 4. Maybe it's evaluating to 3.9999999 or something. Typecasting a double to a int will truncate the value. Meaning, it will just chop of the decimal places...
True. I don't know what I was thinking :)
@OP - You should look into 2-dimensional arrays. I think that is the point of this exercise. You will need to use a 2 for loops (nested) that will loop...
Do you know about 2-dimensional arrays?
myArray[5][5];
double root = pow( num, 1 / 3.0 ) ;
Why is it num ^ 1/3? Instead it should be pow(num, 3) right?
Here is your program with some printf statements that will output what troco is holding at each point in your program. Take a look at the values you are getting when you run it and see if you can...
You could simply ask the user how many students they need and use this number as the size of your array.
Take a look at my new code, it has some comments where I ask questions in it. Do you minding answering those for me?
I am having a bit of trouble creating a function that will determine if a number is a prime number or not. I have attempted various ways to do this, and have read up on the Seive of Eratosthenes....
This looks awesome! I am going to start these right away. Has anyone here been able to solve all of them or a large amount of them?
Hey guys, I am in school for Computer Science. I enjoy programming and really want to develop into a strong programmer. Please post exercises (for C) that will make me a better programmer.
I am a...
Well when I graph sin(x) for instance, the function for all x<0 seems to plot fine. But on the x>0 side it seems to distort. Do you think you can see why in my code?
#include <math.h> //for use...
Perfect, it is working very nicely now. The only imperfection is that I need to space out the intervals (such as x1 x2 x3 etc being too close). Because they are too close it causes graphs like sin(x)...
Sure, it is loss of precision. But if you think about it, we are losing precision on nearly everything all of the time. ;)
Why are you worried about it?