473,387 Members | 1,722 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.

what is wrong with compiling error

When i try to compile:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7.  
  8. /* Function Headers*/
  9. double gravityFactor(double mass, double radius);
  10. double escapeVelocity(double mass, double radius);
  11.  
  12.  
  13. int main(void)
  14. {
  15.      double mass, radius, gf, ev;
  16.      int unit;
  17.  
  18.      double mass_pl[] = {3.3022e23, 4.8685e24, 5.9736e24, 7.3477e22, 6.4185e23,1.8986e27, 5.6846e26,
  19.                         8.6810e25, 1.0243e26};
  20.      double rad_pl[] = {2439700, 6051800, 6371000, 1737100, 3396200, 71492000, 60268000, 25559000, 
  21.                        24764000};     
  22.  
  23.       do
  24.       {
  25.           printf("Select 1 for escape velocities and gravity factors.Select 2 to input own values: ");
  26.           scanf("%d", &unit);
  27.       }while((unit>2)||(unit<1)); 
  28.  
  29.  
  30.  
  31.  
  32.           if(unit==1)  
  33.           {
  34.  
  35.  
  36.                printf("Stellar Body     Gravity Factor    Escape Velocity  \n");
  37.                gf=((mass_pl[0]/mass_pl[2])/((rad_pl[0]/rad_pl[2])*(rad_pl[0]/rad_pl[2])));
  38.                ev =(sqrt((2*(6.67428e-11)*mass_pl[0])/rad_pl[0]))/1000; 
  39.                printf(" Mercury:          %.3f               %.1f km/s\n", gf,ev);
  40.  
  41.                gf=((mass_pl[1]/mass_pl[2])/((rad_pl[1]/rad_pl[2])*(rad_pl[1]/rad_pl[2])));
  42.                ev =(sqrt((2*(6.67428e-11)*mass_pl[1])/rad_pl[1]))/1000;
  43.               printf(" Venus:            %.3f               %.1f km/s\n", gf,ev);
  44.  
  45.                gf=((mass_pl[2]/mass_pl[2])/((rad_pl[2]/rad_pl[2])*(rad_pl[2]/rad_pl[2])));
  46.                ev =(sqrt((2*(6.67428e-11)*mass_pl[2])/rad_pl[2]))/1000; 
  47.                printf(" Earth:            %.3f               %.1f km/s\n", gf,ev);
  48.  
  49.                gf=((mass_pl[3]/mass_pl[2])/((rad_pl[3]/rad_pl[2])*(rad_pl[3]/rad_pl[2])));
  50.                ev =(sqrt((2*(6.67428e-11)*mass_pl[3])/rad_pl[3]))/1000; 
  51.                printf(" Moon:             %.3f               %.1f km/s\n", gf,ev);
  52.  
  53.                gf=((mass_pl[4]/mass_pl[2])/((rad_pl[4]/rad_pl[2])*(rad_pl[4]/rad_pl[2])));
  54.                ev =(sqrt((2*(6.67428e-11)*mass_pl[4])/rad_pl[4]))/1000; 
  55.               printf(" Mars:             %.3f               %.1f km/s\n", gf,ev);
  56.  
  57.                gf=((mass_pl[5]/mass_pl[2])/((rad_pl[5]/rad_pl[2])*(rad_pl[5]/rad_pl[2])));
  58.                ev =(sqrt((2*(6.67428e-11)*mass_pl[5])/rad_pl[5]))/1000; 
  59.                printf(" Jupiter:          %.3f               %.1f km/s\n", gf,ev);
  60.  
  61.                gf=((mass_pl[6]/mass_pl[2])/((rad_pl[6]/rad_pl[2])*(rad_pl[6]/rad_pl[2])));
  62.                ev =(sqrt((2*(6.67428e-11)*mass_pl[6])/rad_pl[6]))/1000; 
  63.                printf(" Saturn:           %.3f               %.1f km/s\n", gf,ev);
  64.  
  65.                gf=((mass_pl[7]/mass_pl[2])/((rad_pl[7]/rad_pl[2])*(rad_pl[7]/rad_pl[2])));
  66.               ev =(sqrt((2*(6.67428e-11)*mass_pl[7])/rad_pl[7]))/1000; 
  67.                printf(" Uranus:           %.3f               %.1f km/s\n", gf,ev);
  68.  
  69.                gf=((mass_pl[8]/mass_pl[2])/((rad_pl[8]/rad_pl[2])*(rad_pl[8]/rad_pl[2])));
  70.                ev =(sqrt((2*(6.67428e-11)*mass_pl[8])/rad_pl[8]))/1000; 
  71.                printf(" Neptune:          %.3f               %.1f km/s\n", gf,ev);
  72.  
  73.  
  74.       }   
  75.                 else if(unit==2)
  76.                 {
  77.  
  78.                     do
  79.                     {
  80.                         printf("Please input the mass of your stellar body(In format:1.9891e30): ");
  81.                         scanf("%lf", &mass);
  82.  
  83.                         printf("Please indicate the radius of your stellar body(In format:1234567): ");
  84.                         scanf("%lf",&radius);
  85.  
  86.                         gravityFactor(mass, radius); 
  87.  
  88.                         escapeVelocity(mass, radius);
  89.  
  90.                         printf("Please select 1 to calculate another planet. Press any number key to terminate: ");
  91.                       scanf("%d", &unit);
  92.  
  93.                    }while(unit==1);
  94.               }
  95.  
  96.   return 0;
  97.  
  98.  
  99. }
  100.  
  101. double gravityFactor(double mass, double radius)
  102. {       
  103.    double gf;    
  104.    gf =((mass/5.9736e24)/((radius/6371000)*(radius/6371000)));  
  105.    printf("The gravity factor of this stellar body is: %.2f\n", gf);
  106.    return gf;     
  107. }  
  108.  
  109.  
  110. double escapeVelocity(double mass, double radius)
  111. {    
  112.    double ev;     
  113.    ev =(sqrt((2*(6.67428e-11)*mass)/radius))/1000; 
  114.    printf("The escape velocity of this stellar body is: %.2f km/s\n", ev);
  115.    return ev;    
  116. }  
  117.  
  118.  
  119.  









i get an error saying that the sqrt is not defined. I am usiing kate text editor for linux? where is sqrt defined when using linux?
Apr 8 '10 #1
2 1305
newb16
687 512MB
If it's a linker error, use -lm switch to link with math library. Text editor doesn't matter in this case.
Apr 8 '10 #2
whodgson
542 512MB
It compiles OK in Dev-C++ and prints the table OK when 1 selected.
Apr 11 '10 #3

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

Similar topics

1
by: sop3k | last post by:
Compiling the code below, by VC++ 6.0 I get an error like this: visual c++\vc98\include\functional(263) : error C2562: '()' : 'void' function returning a value visual...
20
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
7
by: Altemir | last post by:
SOME BACKGROUND: I am new to ASP.NET, but somehow managed to install a perfectly working ..aspx page on our production server that I compiled in Visual Studio. However, I recently needed to...
2
by: teddybyte | last post by:
my script below is: #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, ...
8
by: Skybuck Flying | last post by:
Hello, Visual Studio .Net 2005 (Win32) Compile error: Error 1 error C2804: binary 'operator +' has too many parameters <snipped> line 16 class TSkybuckInt32 { private:
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
2
by: Hukkky | last post by:
File : NodeList.h //---------------------------------------------------------------------- #ifndef NODELIST_H #define NODELIST_H #include <string> using std::string; template <typename T>...
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: 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:
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
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.