473,396 Members | 2,002 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,396 software developers and data experts.

error in C - `system' undeclared (first use this function)

This is my first course in C, I do not know why this error. It did compile before but now this error. Please help..

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5. //Functions
  6. void calc_BMI(double weight, int height);
  7.  
  8.  
  9. int main() {
  10. int height, selection, updated_weight;
  11. float weight;
  12.  
  13.  
  14.      printf("Welcome to the Exercise UCF Program!\n");
  15.  
  16.      printf("What is your height in inches?\n");
  17.      scanf("%d", &height);
  18.  
  19.      printf("What is your weight in pounds?\n");
  20.      scanf("%f", &weight);
  21.  
  22.      printf("Please Select One of the Following:\n");
  23.      printf("1 - Update Weight\n");
  24.      printf("2 - Calculate BMI\n");
  25.      printf("3 - Calorie Counter\n");
  26.      printf("4 - Weight Calculation\n");
  27.      printf("5 - Average Mile\n");
  28.      printf("6 - Quit\n");
  29.      scanf("%d", &selection);
  30.  
  31.      switch (selection) {
  32. //enter weight
  33.            case 1:
  34.                 printf("What is your current weight in pounds?\n");
  35.                 scanf("%d", updated_weight);
  36.  
  37.                 break;
  38. //Calculate BMI
  39.            case 2:
  40.                 if (weight < 1000 && height < 100) 
  41.                   calc_BMI(weight, height);
  42.  
  43.                 //if(body_mass_index <= 18.5)
  44.                 //printf("Your body weight status is underweight.\n");
  45.  
  46.                 //if(body_mass_index >= 18.5 && body_mass_index <= 24.9)
  47.                 //printf("Your body weight status is normal.\n");
  48.  
  49.                 //if(body_mass_index >= 25 && body_mass_index <= 29.9)
  50.                 //printf("Your body weight status is overweight.\n");
  51.  
  52.                 //if(body_mass_index > 30)
  53.                 //printf("Your body weight status is obese.\n");
  54.                 break; 
  55.                 }
  56.                 system ("pause");
  57.      return 0;
  58.  
  59.      }
  60.  
  61.  
  62. //BMI
  63. void calc_BMI(double weight, int height) {
  64.      double body_mass_index = 0;
  65.  
  66.      body_mass_index = weight*703/(height*height);
  67.  
  68.      if(body_mass_index <= 18.5)
  69.        printf("Your body weight status is underweight.\n");
  70.  
  71.      if(body_mass_index >= 18.5 && body_mass_index <= 24.9)
  72.        printf("Your body weight status is normal.\n");
  73.  
  74.      if(body_mass_index >= 25 && body_mass_index <= 29.9)
  75.        printf("Your body weight status is overweight.\n");
  76.  
  77.      if(body_mass_index > 30)
  78.        printf("Your body weight status is obese.\n");
  79.  
  80.  
  81. }
Jul 30 '11 #1
1 17394
system is in stdlib.h
Just add line
Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
at the begining of the program.
Jul 30 '11 #2

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

Similar topics

1
by: learning_C++ | last post by:
Hi, I compiled some code which includs times<int>(). The compiler says "times' undeclared (first use this function)". I also included the header <functional> in my code. But After I replaced...
2
by: kyung seop kim | last post by:
hi! all I updated compiler to gcc 3.4.3 in suse linux machine. I met the error message like subject. how can I fix this problem ?
2
by: Simon Harris | last post by:
I have created a web service, which when I call in my browser presents the text form etc. When I click the button, I get this error: System.ArgumentException: Cannot convert to System.Int32....
4
by: Peter Rothenbuecher | last post by:
Hello, when I try to compile the following code: /* This fragment of code is taken from an online tutorial */ #include<stdio.h> #include<fcntl.h> #include<stdlib.h> float bigbuff;
6
by: Peter Rothenbuecher | last post by:
Hello, when I try to compile the following code with g++ -o client client.c #include<sys/socket.h> #include<stdio.h> #include<stdlib.h> #define ADDRESS "mysocket"; #define MAXLEN 200;
7
by: michigaki | last post by:
hello, we are having problems in compiling a 'slightly' altered x264. We are always receiving a 'helloWorld' undeclared (first use this function) error. We may be commiting a very simple error but...
2
by: CodeTilYaDrop | last post by:
I need help again. This is probably an easy fix, but I can not figure this out. It is late, and this probably explains why I can't figure it out. This is my error 'positive' undeclared (first...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
1
by: Harshini Raj | last post by:
Hi, I am unable to fix this error. Canyou tell me what compiler options i have to use to fix this issue? Issue Error 40:Undeclared identifier 'Name' -- Within an expression, an identifier was...
2
by: Richard Ballin | last post by:
Hello All, I am taking a class using Visual Studio C++ Express 2010 and on one of the first projects i need to use the Math::Pow() function. The book does not do a good job of explaining how to...
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?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.