We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# Reverse the dispaly?

on
Medium Priority
224 Views
how do I reverse the order of display numbers using the values stored in the array. The code listed below works fine in ascending order but acn seem to get the puppy to reverse.
/* Fibonacci Series */
/* Assignment 8 */

main()

{       int a[22];
int index;

a[0] = 0;
a[1] = 1;

printf("Fibonacci\n");
printf("a[ 0] = %5d\n", a[0]);
printf("a[ 1] = %5d\n", a[1]);

for (index=2; index < 22; index++)

{
printf("a[%2d] = ", index);
a[index] = a[index-1] + a[index-2];
printf("%5d   ", a[index]);
printf("%5d   ", a[index] - a[index-1]);
printf("%f\n", (float) a[index] / (float) a[index-1]);
}

}
thanks
Comment
Watch Question

## View Solution Only

Commented:
Hi patricd,

I'm not sure I understand what you are trying to say. Do you just want to display the no in the array in descending order??

If so, you could do this easily using the following loop. Add this code at the end

printf("Fibonacci - in reverse\n");

for (index=21; index > 1; index--)
{
printf("a[%2d] = ", index);
printf("%5d ", a[index]);
printf("%5d ", a[index] - a[index-1]);
printf("%f\n", (float) a[index] / (float) a[index-1]);
}

printf("a[ 1] = %5d\n", a[1]);
printf("a[ 0] = %5d\n", a[0]);

Hope this helps. If this is not what you are looking, lemme know

Wilfred

Commented:
this worked like a charm...thanks
Commented:
Refer to my comment for the answer

patricd, I am answering this for points

Thanks,
Wilfred

Not the solution you were looking for? Getting a personalized solution is easy.

##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile