0

I have a strange request, but I just need to output the array. I wrote the code, but my teacher asked me to also print the input array. I don't understand how to implement this correctly in my case. Here is my code :

#include <stdio.h>
int main() {
    float a[15], q = 1.5;
    a[0] = 2.0;
    for (int i = 1; i < 15; i++) {
        a[i] = a[i - 1] * q;
    }
    for (int i = 0; i < 15; i++) {
        printf("%i  %4.2f\n", i, a[i]);
    }
}
VillageTech
  • 1,968
  • 8
  • 18
  • What's the problem with what you currently have? Doesn't it output the array already? – kaylum Dec 09 '19 at 21:23
  • I don't see a problem with the code *assuming* it is implementing what it should. – Eugene Sh. Dec 09 '19 at 21:25
  • 1
    "My teacher asked me to also print the input array", theres only one array here. I suspect your misunderstanding the assignment. – Bwebb Dec 09 '19 at 21:28
  • 3
    I'd guess your teacher means print out the array before it's modified, then again after it's modified.. but if you don't know you need to ask. Since it's not initialized (except for `a[0]`), you'll just see a bunch of random data ... maybe that's the point. – yano Dec 09 '19 at 21:29

0 Answers0