Like Tree1Likes
  • 1 Post By iMalc

Double problem

This is a discussion on Double problem within the C Programming forums, part of the General Programming Boards category; I am new to programming, learning online and via books. Would appreciate help with this Double error, which states: $g++ ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    2

    Double problem

    I am new to programming, learning online and via books. Would appreciate help with this Double error, which states:

    $g++ /tmp/13642987312818.cpp -o /tmp/13642987312818 -lm 2>&1
    /tmp/13642987312818.cpp: In function 'int main()':
    /tmp/13642987312818.cpp:33: error: expected primary-expression before 'double'
    /tmp/13642987312818.cpp:33: error: expected `;' before 'double'

    Code:
    #include <stdio.h>
    #include <math.h>
    
    #define C 3
    
    int main() 
    {
    
      int v, w;
      float f;
      int i, e;
      double x;
    
          char n[4];
          printf ("Which species?\n");
          scanf(" %s",n);
          printf(" %s\n",n);
          printf ("What Vm?\n");
          scanf (" %d",&v);
          printf(" %d\n", v);
    
      printf("Conc in?\n");
      scanf(" %d",&i);
      printf(" %d\n", i);
    
      printf("Conc out?\n");
      scanf(" %d",&e);
      printf(" %d\n", e);
    
      w=i+e;
    
      x=double log(w);
    
      f = v - (C*x);
    
      printf("%f\n",f);
      return 0;
    }
    Input:
    Ca2+
    -60
    15
    150

    Thanks !

  2. #2
    Registered User
    Join Date
    Mar 2013
    Posts
    2
    I will answer my own question :
    Remove previous Double declaration, and replace ln function with:
    double x=log(w);

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,307
    Almost...
    Doing that would leave it conflicting with the definition of x on line 12.
    You probably mean to just remove "double" from line 32 altogether.
    NBK Rules likes this.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Double While Loop Problem
    By Bryan Lassiter in forum C Programming
    Replies: 2
    Last Post: 02-15-2013, 08:51 AM
  2. Problem with abs(double)
    By Elnaz in forum C++ Programming
    Replies: 3
    Last Post: 01-29-2011, 06:57 PM
  3. Double problem
    By cs05pp2 in forum C Programming
    Replies: 11
    Last Post: 10-16-2009, 02:03 PM
  4. double pointer problem
    By a0161 in forum C Programming
    Replies: 4
    Last Post: 05-10-2009, 07:52 AM
  5. double value switch problem
    By axon in forum C++ Programming
    Replies: 4
    Last Post: 02-14-2003, 04:03 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21