Forum Settings
       
Reply To Thread

Anyone good with C? :(Follow

#1 Aug 02 2008 at 8:53 PM Rating: Decent
Scholar
****
4,731 posts
Basically I'm only just getting started and trying to get to grips with:

(funct. 1 here);
while(funct. 2 here);
(funct. 3 here);

and doing this by writing a script that will take two numbers, b > a, and work out what a*(a+1)*(a+2)*...*(b) is. In other words (b factorial)/(a factorial)

Right now I'm learning by taking notes from a guy explaining it to me (I'm going to get a decent book soon) and they're pretty confused. I think the code should look like

int VAR(int a, int b);
int a = 3;
int b = 6;
int h;
h=a;
h=h*(++a);
while(a!=h){
a=a+1;
h=h*a;
return h;
}

But the software I'm using to test it (Ch student) is shutting down whenever I do this. Could someone correct it for me? Once I know how it should look it'll be easier to work out how it does work.
#2 Aug 04 2008 at 4:20 AM Rating: Decent
Lunatic
******
30,086 posts
One, unless you're doing programming homework, just use Mathmatica, anyway:

[code]
int factorial( int n )
{
int fact = 1;

while ( n > 1) {
fact = fact * n;
n = n - 1;
}
return fact;
}
[/code]

Then just call the function as factorial (a)/factorial(b) or whatever.

good luck.

____________________________
Disclaimer:

To make a long story short, I don't take any responsibility for anything I post here. It's not news, it's not truth, it's not serious. It's parody. It's satire. It's bitter. It's angsty. Your mother's a *****. You like to jack off dogs. That's right, you heard me. You like to grab that dog by the bone and rub it like a ski pole. Your dad? Gay. Your priest? Straight. **** off and let me post. It's not true, it's all in good fun. Now go away.

#3 Aug 04 2008 at 4:53 AM Rating: Decent
Scholar
****
4,731 posts
Thanks, that seems a lot simpler than what I was aiming at.

This is just practice in programming, I would borrow a scientific calculator if the results were important. :p
#4 Aug 04 2008 at 8:20 AM Rating: Good
I have a C class this fall, I'm wondering how much my experience with C# will ***** me up in C.
#5 Aug 04 2008 at 9:15 AM Rating: Decent
Lunatic
******
30,086 posts

I'm wondering how much my experience with C# will ***** me up in C.


Not much. What it will do is cause you to think "this is a ******* retarded way to do this" on occasion.
____________________________
Disclaimer:

To make a long story short, I don't take any responsibility for anything I post here. It's not news, it's not truth, it's not serious. It's parody. It's satire. It's bitter. It's angsty. Your mother's a *****. You like to jack off dogs. That's right, you heard me. You like to grab that dog by the bone and rub it like a ski pole. Your dad? Gay. Your priest? Straight. **** off and let me post. It's not true, it's all in good fun. Now go away.

#6 Aug 04 2008 at 10:35 AM Rating: Good
Retarded in C or C#? Or both?

I like C#, I see quite a few elements of JavaScript and C in it (what little C I know anyway). I'm hoping I can cruise through this class because Calc II is going to give me bigger problems.
#7 Aug 04 2008 at 10:42 AM Rating: Decent
Lunatic
******
30,086 posts

Retarded in C or C#? Or both?


Largely in C.

____________________________
Disclaimer:

To make a long story short, I don't take any responsibility for anything I post here. It's not news, it's not truth, it's not serious. It's parody. It's satire. It's bitter. It's angsty. Your mother's a *****. You like to jack off dogs. That's right, you heard me. You like to grab that dog by the bone and rub it like a ski pole. Your dad? Gay. Your priest? Straight. **** off and let me post. It's not true, it's all in good fun. Now go away.

Reply To Thread

Colors Smileys Quote OriginalQuote Checked Help

 

Recent Visitors: 74 All times are in CST
Anonymous Guests (74)