473,378 Members | 1,372 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,378 software developers and data experts.

Call of nonfunction & Misplace else

Need help here..Sorry still new in programming

I have an assignment which is quadratic formula and using if and else but i have some errors but i don't know what to do.... here's the program

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <math.h>
  4.  
  5. float a,b,c,determinant,x_1,x_2;
  6.  
  7. void main()
  8.     {
  9.     clrscr();
  10.     printf("\nEnter the value of a:",a);
  11.     scanf("%d",&a);
  12.     printf("\nEnter the value if b:",b);
  13.     scanf("%d",&b);
  14.     printf("\nEnter the value of c:",c);
  15.     scanf("%d",&c);
  16.     determinant=sqrt((b*b)(4*a*c));
  17.  
  18.     if (determinant >=0);
  19.     {
  20.     x_1=((-b)+sqrt(determinant))/(2*a);
  21.     x_2=((-b)-sqrt(determinant))/(2*a);
  22.     printf("\n\nx_1 = %.02f",x_1);
  23.     printf("\n\nx_2 = %.02f",x_2);
  24.     }
  25.  
  26.     else
  27.     {
  28.     printf("\nThe input is invalid!\n");
  29.     }
  30.  
  31.     getch();
  32.  
  33.     }
  34.  
Error NONAME00.CPP 16: Call of nonfunction
Error NONAME00.CPP 26: Misplace else

Need help please...
Jul 3 '12 #1
2 2095
weaknessforcats
9,208 Expert Mod 8TB
This code:

Expand|Select|Wrap|Line Numbers
  1. if (determinant >=0); <--- remove semi-colon
  2.  {
  3.  x_1=((-b)+sqrt(determinant))/(2*a);
  4.  x_2=((-b)-sqrt(determinant))/(2*a);
has a semi-colon in the if which terminates the the if. Your sqrt calls are missing a pair of of parentheses. You must use
sqrt(determinant/(2*a)).

Lastly, floats are not meant to be used with the equality operator like == or >= or <=. The reason is that floats are rounded so that something close to equal might be tested as equal. For beginners I wouls use an int for the determinant or I would research how to compare floating point numbers.
Jul 3 '12 #2
donbock
2,426 Expert 2GB
Another issue is that your variables are "float", but you ask scanf to store integers (%d) in them. That won't do what you want.
Jul 4 '12 #3

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

Similar topics

27
by: Jason Shohet | last post by:
I have an ascx control, and it needs a value called 'orgID' which the parent page will have. I want to avoid the parent page setting values in fields on the ascx control since this violates...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.