C programming help, printing arrays in reverse order?
ok im endeavoring to write some sort of void functionality that posters the things in a spectrum in inverted order but it is not working i’m unsure what im doing wrong
i rescued this as a chf file and played it applying ch
emptiness printReverse(double d, int n)
int my partner and i;
regarding (i=0; i<n; i++)
print(“%lf\n”, dn-i-1);
try this
emptiness printReverse(double d, int n)
int my partner and i;
for(i=(n-1); i>=0; i–)
printf(“%lf\n”, di);
You’re not really defining ‘d’ as a possible array, it’s merely a double.Look at:
emptiness printReverse(double d, int n)
Likewise, it would make more sense to decrement the actual index
regarding (; n<=0; n–)
printf(“%lf\n”, dn-1);
It is really easier for you to read.
why now don’t just be counted backwards rather then inside that printf function
something just like this:
for(i=n-1; i>=0; i–)
…
Leave a Reply
You must be logged in to post a comment.