I am trying to write a code in C that generates a random integer , performs simple calculation and then I am trying to print the values of the file in IEEE standard. But I am unable to do so , Please help.
I am unable to print it in Hexadecimal/Binary which is very important.
If I type cast the values in fprintf, I am getting this Error expected expression before double.  
int main (int argc, char *argv) {
     int limit = 20 ; double a[limit], b[limit];                //Inputs
     double result[limit]    ; int i , k ;            //Outputs
     printf("limit = %d", limit ); double q;
     for (i= 0 ; i< limit;i++)
         {
         a[i]= rand();
         b[i]= rand();
         printf ("A= %x B = %x\n",a[i],b[i]);
         }
     char op;
      printf("Enter the operand used : add,subtract,multiply,divide\n"); 
     scanf ("%c", &op); switch (op) {
     case '+': {
             for (k= 0 ; k< limit ; k++)
                 {
                 result [k]= a[k] + b[k];
            printf ("result= %f\n",result[k]);
                 }
             }
         break;
     case '*': {
             for (k= 0 ; k< limit ; k++)
                 {
                 result [k]= a[k] * b[k];
                 }
             }
         break;
     case '/': {
             for (k= 0 ; k< limit ; k++)
                 {
                 result [k]= a[k] / b[k];
                 }
             }
         break;
     case '-': {
             for (k= 0 ; k< limit ; k++)
                 {
                 result [k]= a[k] - b[k];
     }
             }
         break; }
     FILE *file; file = fopen("tb.txt","w"); for(k=0;k<limit;k++) {  
     fprintf (file,"%x\n
     %x\n%x\n\n",double(a[k]),double(b[k]),double(result[k]) );
     }
     fclose(file); /*done!*/
 }
 
     
     
     
    