:: [DNG] continuing in C programming
Etusivu
Poista viesti
Vastaa
Lähettäjä: o1bigtenor
Päiväys:  
Vastaanottaja: Devuan ML
Aihe: [DNG] continuing in C programming
Greetings

(using gcc compiler - - just in case that makes a difference
book is 'Modern C')

program is :

/* This may look like nonsense, but really is -*- mode: C -*- */
#include <stdlib.h>
#include <stdio.h>

/* The main thins that is program does. */
int main(void) {
   //Declarations
   double A[5] = {
      [0] = 9.0,
      [1] = 2.9,
      [4] = 3.E+25,
      [3] = .00007,
   };


   //Doing some work
   for (size_t i=0; i < 5; ++i) {
      printf("element_%zu_is_%g,_\tits_square_is_%g\n",
             i,
             A[i],
             A[i]*A[i]);
   }


return EXIT_SUCCESS;
}

When I run it I'm getting :

$ ./firstprogram
element_0_is_9,_    its_square_is_81
element_1_is_2.9,_    its_square_is_8.41
element_2_is_0,_    its_square_is_0
element_3_is_7e-05,_    its_square_is_4.9e-09
element_4_is_3e+25,_    its_square_is_9e+50


I don't think all the underscores are supposed to be there - - - what
did I do wrong?

TIA