Hi,
Right now my program runs a beautiful pascal triangle up to 5. The only problem is that I want the user's input n to be the last row the triangle prints. When I replace n for in 5 in the first for loop it doesn't print the triangle. I know it's something simple. I've been focused so many hours trying to get this to work I've forgotten the basics..maybe.
[CODE=cpp]int factorial (int n)
{
if...
User Profile
Collapse
-
Pascal_Triangle
-
int my_gcd (int *m, int *n)
{
while (m > 0)
{
if (n > m)
{ int t = m; m = n; n = t; }
m -= n;
}
} -
Gcd
Can anyone help me with coding the GCD? I want to take two integers 56 and 42 and divide them x amount of times until the remainder is 0. Once the remainder is 0 that divisor becomes my GCD. -
simplify fractions
I'm having a hard time figuring out how to simplify the fractions. Can anyone look at this code and see if you can see something I don't.
[CODE=c]//This is the fraction adding function
void add_fractions (int a, int b, int c, int d, int *ansn, int *ansd)
{
//int e, x, y, rem, gcd;
a = a*d; //numerator 1 * denominator 2
c = c*b; //numerator 2 * denominator 1
b = b*d; // denominator 1 * denominator... -
Would you add two new variables and nest a decremented double for loop? With k being greater than or equal to n?Leave a comment:
-
Nested Loops
Hi, I'm trying to draw:
0
01
012
0123
01234
0123
012
01
0
So far I have the beginning for (i=1; i<=n; ++i)
{ for (j=0; j<i; ++j)
{printf("%d ", j);}
printf("\n" );
...
No activity results to display
Show More
Leave a comment: