473,387 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Illegal Use of pointer

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
1 4203
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

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

Similar topics

10
by: quantdev2004 | last post by:
Hi all, I have been deling with this kind of code: class Foo { public: void NonConstMethod() {} };
12
by: Andreas Schmidt | last post by:
I am trying to understand the behavior of void pointers. Can someone explain to me why I get a segfault for the following program? #include <stdio.h> void* plusone(void* i){ int* arg =...
0
by: Bruno van Dooren | last post by:
Hi, I am debugging a dll that is used in an application that calls all functions with C calling conventions, and cannot handle exceptions. Every 1-2 months there is a crash due to an unhandled...
21
by: Roman Werpachowski | last post by:
I can't understand this: double * x = new double; const double * p = x; delete p; works. Why am I allowed to delete a const pointer? On the same note: why am I allowed to do this: class...
9
by: Roshni | last post by:
Hi, I wanted to know how do function pointers sometime access illegal memory access ? Could any one give me an example ? Thanks, Roshni
30
by: Joe Smith | last post by:
A recent post of mine showed a sufficiently large gaffe on pointers as to need to return to K&R 5.1-6 appendix A8.6.1 . So we have type specifiers: int long .. One dreams himself variable...
11
by: asdf | last post by:
C++ allows a reference to a pointer, but doesn't allow a pointer to a reference, why?
11
by: Christopher Key | last post by:
Hello, Can anyone suggest why gcc (-W -Wall) complains, test.c:22: warning: passing arg 1 of `f' from incompatible pointer type when compiling the following code? Change the declation of f...
26
by: =?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Do you think we can reach any kind of consensus on whether the following code's behaviour is undefined by the Standard? int my_array; int const *const pend = *(&my_array + 1); Considering...
18
by: Richard Eich | last post by:
I need a clue. I'm getting an "invalid lvalue in increment" from gcc 4.1.2 on this line... sum += *((unsigned short *)iphp)++ ; ....but I don't see what the problem is. gcc 3.4.3 isn't...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.