Illegal Use of pointer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Abin Hasan

    Illegal Use of pointer

    Code:
    #include<stdio.h>
     #include<conio.h>
     #include<math.h>
     #include<stdlib.h>
     void main ()
     {
      float a, b, c, d, x1, x2;
      clrscr();
      printf("Enter value for a b  & c\n");
      scanf("%f %f %f",&a,&b,&c);
      d=b*b-4*a*c;
      if(d<0)
      printf("Roots r imaginary");
      else
      {
      x1=(-b+sqrt*d)/(2*a);
      x2=(-b-sqrt*d)/(2*a);
      printf("x1=%.3f x2=%.3f",x1,x2);
      }
      getch();
     }
    Last edited by MMcCarthy; Oct 20 '10, 09:20 PM. Reason: added code tags
  • rstiltskin
    New Member
    • Feb 2010
    • 14

    #2
    Lines 16-17 should be:

    Code:
      x1=(-b+sqrt(d))/(2*a);
      x2=(-b-sqrt(d))/(2*a);
    because d is the argument that you are supplying to the sqrt function.

    Also, in order to comply w ith the C language standard, the return value of your main function should be int, not void, i.e.:
    Code:
    int main ()

    Comment

    Working...