If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

how do I construct mulitple functions (one for substration and division) and print the numbers based on Fibonacci series.

Ihave included the basic code for the first part of the program...I need to add a function to subtract and display the difference between succeeding numbers and also a function to calculate and display the quotients of the succeeding series in a third colum.

the display might look like this:

0

1 0 1.000000

2 1 2.000000

3 2 1.500000

5 3 1.666667

8 5 1.600000

13 8 1.625000

and so on...

/* Fibonacci series */

/* Assignment 7 */

int a = 0, b = 1, c = 0;

main()

{

int sum();

int subtract();

printf("Fibonacci\n");

printf("%5d \n", a);

printf("%5d \n", b);

do

{

c = sum(a, b);

printf("%5d\n", c);

a = b;

b = c;

}

while (c < 10000);

}

int sum(x, y)

int x, y;

{

return x + y;

}

I' ve complied this portion and it works but everything I try fro the next function is a bust...any HELP would be appreciated. Thanks

Ihave included the basic code for the first part of the program...I need to add a function to subtract and display the difference between succeeding numbers and also a function to calculate and display the quotients of the succeeding series in a third colum.

the display might look like this:

0

1 0 1.000000

2 1 2.000000

3 2 1.500000

5 3 1.666667

8 5 1.600000

13 8 1.625000

and so on...

/* Fibonacci series */

/* Assignment 7 */

int a = 0, b = 1, c = 0;

main()

{

int sum();

int subtract();

printf("Fibonacci\n");

printf("%5d \n", a);

printf("%5d \n", b);

do

{

c = sum(a, b);

printf("%5d\n", c);

a = b;

b = c;

}

while (c < 10000);

}

int sum(x, y)

int x, y;

{

return x + y;

}

I' ve complied this portion and it works but everything I try fro the next function is a bust...any HELP would be appreciated. Thanks

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's a fairly inefficient code but it should serve

I will leave it to you to improverise and implement these functions

please contact me if you have difficulties

regards

NewGuy

---------------------

/* f here == fibanocci */

int f(int n)

{

if (n == 0 || n == 1)

return 1;

else return (f(n-1) + f(n-2));

}

int difference(int n)

{

return (f(n) - f(n-1));

}

double quotient(int n)

{

return ((double) f(n)/f(n-1));

}

/* Fibonacci series */

/* Assignment 7 */

main()

{

int a = 0, b = 1, c = 0; /* no need to make these global - its bad programming practice */

/* get rid of int sum();, what's the point? */

/* same for int subtract(); */

printf("Fibonacci\n");

printf("%5d \n", a);

printf("%5d \n", b);

do

{

c = sum(a, b);

printf("%5d %5d %8.6f\n", c, b, (double)c/b);

a = b;

b = c;

}

while (c < 10000);

}

/* get rid of this ...

int sum(x, y)

int x, y;

{

return x + y;

}

*/

Roger

/* Top of File */

#include <stdio.h>

int main(void)

{

puts( "Fibonacci Numbers."

" Fn | dif Fn | Quot"

"------+--------+---------

);

for(int a = 0, b = 1, c = 0; c < 10000; c = a + b, a = b, b = c)

printf("%5d | %5d | %6f\n", b, a, (float)b / a );

return 0;

}

/* End of File */

Actually I wanted it as a one liner but added the puts() to give the tabel a nicer look.

.luc.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialputs( "Fibonacci Numbers.\n"

" Fn | dif Fn | Quot\n"

"------+--------+---------

);

.luc.

Here is the correct version. (spot the difference)

/* Top of File */

#include <stdio.h>

int main(void)

{

puts( "Fibonacci Numbers.\n"

" Fn | dif Fn | Quot\n"

"------+--------+---------

);

for(int a = 1, b = 1, c = 0; c < 10000; c = a + b, a = b, b = c)

printf("%5d | %5d | %6f\n", b, a, (float)b / a );

return 0;

}

/* End of File */

.luc.

I provided you with an answer and it was just rejected without any explanation as to why or what was wrong.

I don't know if I'll answer anymore questions from you if you don't have the courtesy to explain WHY you are rejecting and to give the person who answered a chance to correct !!!

:-)

Please be more considerate to the experts next time

C

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.