By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Illegal Use of pointer

P: n/a
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  #include<conio.h>
  3.  #include<math.h>
  4.  #include<stdlib.h>
  5.  void main ()
  6.  {
  7.   float a, b, c, d, x1, x2;
  8.   clrscr();
  9.   printf("Enter value for a b  & c\n");
  10.   scanf("%f %f %f",&a,&b,&c);
  11.   d=b*b-4*a*c;
  12.   if(d<0)
  13.   printf("Roots r imaginary");
  14.   else
  15.   {
  16.   x1=(-b+sqrt*d)/(2*a);
  17.   x2=(-b-sqrt*d)/(2*a);
  18.   printf("x1=%.3f x2=%.3f",x1,x2);
  19.   }
  20.   getch();
  21.  }
Oct 20 '10 #1
Share this Question
Share on Google+
1 Reply


P: 14
Lines 16-17 should be:

Expand|Select|Wrap|Line Numbers
  1.   x1=(-b+sqrt(d))/(2*a);
  2.   x2=(-b-sqrt(d))/(2*a);
  3.  
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.:
Expand|Select|Wrap|Line Numbers
  1. int main ()
  2.  
Oct 21 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.