C/C++ :: Error When Trying To Program BMI Calculator

Aug 26, 2014

'm trying to program a BMI calculator in C for my assignment where the weight must be in KG and an int , and the height must be in m and a double value. The program should allow the user to input his weight(kg) and height(m) separated by a space and be able to calculate and display the BMI. My code is shown below :

#include<stdio.h>
int
main(void) {
int weight;
double height,bmi;
bmi = weight / ( height * height ) ;
scanf("%d%lf" , &weight , &height );
printf("BMI = %f", bmi);
return 0;
}

However , after running the program , I constantly get a 1.#INF00 value for my result.The compiler did not show any errors so why I'm getting this value.I input my weight and height in this format "45 1.65" 45 being the weight and 1.65 being the height.

View 3 Replies


ADVERTISEMENT

C/C++ :: Calculator - Correcting For User Error

Jan 19, 2014

I have am having a bit of trouble with a baisc calculator that I am writing for my intro to programming class at Uni. We are using the C programming language. The program is supposed to be able to add, subtract, multiply, and divide. It is also supposed to return certain messages if an error has occurred. This is how the program is supposed to perform:

bash-4.2$ ./calc
enter expression: 4.25 * 3.3
result: 14.025

[Code]....

View 5 Replies View Related

C++ ::  Calculator Program - Function Does Not Take 0 Arguments

Jan 29, 2014

I am supposed to get 2 numbers then have the person choose what they want to do to the numbers. Here is the code:

//Mike Karbowiak
//12/24/13
//Mathematics
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

[Code] ....

The errors I am getting so far are:

error C2660: 'Add' : function does not take 0 arguments
error C2660: 'Subtract' : function does not take 0 arguments
error C2660: 'Multiply' : function does not take 0 arguments
error C2660: 'Divide' : function does not take 0 arguments

View 3 Replies View Related

C++ :: Cone Volume Calculator Program

Nov 6, 2014

I'm working on below program and I want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one user defined function called computeConeVolume that contains the calculation. In other words I want to remove the one line calculation and replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax that I need to complete it.

The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output. Should be able to declare "global" variables anywhere but no variables above or outside of main() and the function are allowed. A value-returning function should be used because it's a little simpler to understand, but you can employ a void function. Need to have a function prototype at the top of the code, then main, then your function.

//Cone Volume Calculator Program
#include <iostream>
using namespace std;
int main( ) {
//Declare variables and constants
double coneRadius = 0.0;
double coneHeight = 0.0;

[Code] ....

View 6 Replies View Related

C++ :: Calculator Program - How To Do Sine Calculation

Apr 26, 2013

I am basically trying to make a program for a calculator. I am struggling with how to do the sine calculation. this calculation will take place at line 158.

#include <iostream>
#include <cmath>
using namespace std;
int main() {

double firstNumber = 0.0;
double secondNumber = 0.0;
char operation =' ';

[Code] ....

View 1 Replies View Related

C :: Program That Have Starting Menu For A Calculator Using If / Else Statement

Sep 21, 2014

I just started learning C and trying to create a program in C that will have a starting menu for a calculator. The problem is that I could do that with a switch/case but the assignment requires me to use if/else.

Here's what I have so far:

Code:

#include <stdio.h>
int calc();
int menu();
int main() {
printf("Hello. Welcome to the program.
");
printf("Press RETURN key to continue...

[Code]...

How should I go from now using if/else to have those 4 choices?

View 5 Replies View Related

C :: Making Calculator Program Using Only Getchar And Putchar

Mar 21, 2014

I have to make a calculator program that has 5 different functions (this is obviously the easy part, once all the input is assigned to their respective variables), which are addition, subtraction, mod, multiplication and division (negatives are not allowed, and must be error-checked; spaces must be ignored). I need to take the equation from the user, echo it back and then solve the problem.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

[Code].....

View 4 Replies View Related

C++ :: Write A Postfix Calculator Program Using Stack

Dec 14, 2013

i try to write a postfix calculator program using stack in C++ the in put must be the infix expression but can dont know how to write a infix expression in put.

this is my code :

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <conio.h>
using namespace std;
}

[code]....

View 2 Replies View Related

C :: Creating Simple Calculator By Splitting The Program In 3 Files

Feb 21, 2014

I am new to C programming, I have been given an assignment to create a simple calculator by splitting the program in 3 files. It should have 2 .c files and 1 .h... I went through the internet extensively and could only come up with this.

main.c:

Code:

//Calculator main.c
#include <stdio.h>
#include <conio.h>
#include "Functions.h"
int main() {
float x = 0, y = 0;
int operation;

[Code]...

Functions.c

Code:

#include "Functions.h"
extern float x, y;
float addition (float a, float b) {
return a + b;

[Code]...

Functions.h

Code:

#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
float Sum(float a, float b);
float difference (float a, float b);
float remainder (float a, float b);
float product (float a, float b);
#endif

When I do a 'cl main.c' on the Developer Command window for VS2013, i get an error that reads :

main.obj
main.obj : error LNK2019: unresolved external symbol _difference referenced in function _main
main.obj : error LNK2019: unresolved external symbol _product referenced in function _main
main.obj : error LNK2019: unresolved external symbol _addition referenced in function _main
main.exe : fatal error LNK1120: 3 unresolved externals

View 5 Replies View Related

C++ :: Incorporate Button Into Current Program That Opens Up Calculator?

Nov 10, 2013

I want to incorporate a button into my current program that opens up a calculator in a different window. I have the code for the calculator and the program. I have never worked with buttons or windows.

View 4 Replies View Related

C++ :: Reverse Polish Calculator - How To Make Program Exit If User Enters Only 0

Oct 11, 2013

I have my Reverse Polish calculator compiling and everything but for the assignment I need to handle a few exceptions that I can't seem to get. First off I'm trying to make the program exit if the user enters only "0" but since the input i'm using is string, I cant figure out how to code

"If the first node is 0 and the next node = NULL, return true"

Here is my code:
#include<iomanip>
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string>
#include<sstream>
using namespace std;

class Stack {

[Code] .....

View 1 Replies View Related

C/C++ :: Can't Run The Program Because Of Error

Nov 15, 2014

my code is :
#include<stdio.h>
int main();
{
printf("????
");
return 0;
}

error: expected identifier or '(' before '{' token
what do I have to do to run it?

View 1 Replies View Related

C/C++ :: Encryption Program Error

Aug 5, 2014

Back again with a random bug that I can't seem to track down. My error is in my main.cpp file. I get a C2248 error on line 54, there I'm doing:

t.makeEmpty(t.root)

I know why, because it's a private member...but it should have access in so far as everything is concerned. I double checked my makeEmpty code and it's good to go so far as I can tell. I can't quite iron out where the disconnect is.

V/R
Brad
main.cpp
#include <iostream>
#include <string>

[Code].....

View 4 Replies View Related

C++ :: Open Program Error Notification

Mar 23, 2013

I've almost finished a Terminal/Command Prompt Program that can do most of the things a Microsoft or Linux Terminal can do - but I have a problem. I've got it to open programs fine, and I can also open their browser to the download page if they don't have it, but I need my program to know if there isn't the software so a bit like command prompt where it says 'The system cannot find the file test.txt.' and then it'll take them to the website if they like.

View 2 Replies View Related

C :: Array Program - Parse Error Before INT

Sep 18, 2013

this program is just to give the size and value of the array by the user.

Code:
#include <stdio.h>
main( ) {
int size ;
scanf ( "%d", &size ) ;
int arr[size] ;
for ( i = 1 ; i <= size ; i++ ) {
scanf ( "%d", arr[i] ) ;
printf ( "%d", arr[i] ) ;
}

error : Code:
C:UsersDocumentsprog est.c:7: parse error before `int'

View 7 Replies View Related

C++ ::  Error In Prime Numbers Program

Jan 29, 2013

Here is what I have:

#include <iostream>
#include <cmath>

using std::cout;
using std::endl;
using std::cin;

[Code] .....

This is the output after compiling when I enter 10 as 'x':
3
5
5
5
7
7
7
7
7
9

View 1 Replies View Related

C++ ::  Palindrome Program Compile Error

Jan 16, 2014

Here is the code which I wrote in Turbo C++...its giving errors..

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
voidmain() {
clrscr();

[code]....

View 8 Replies View Related

C++ :: Finding Multithread Program Error?

Aug 3, 2013

How do I find an error in a multithreading program (written in C)? I get an address, but when I put it into psp-addr2line, i get

??
??:0

View 2 Replies View Related

C++ :: Payroll Program - Calculation Error?

May 22, 2014

I'm working on a payroll program and I'm having problems that are causing calculation errors.

My input file is
1234FredJones4025.00
2345 TerrySmith6010.00

The errors I get are from the regular pay, over time pay, gross pay, tax amount and net pay calculations. They all look similar to this (6e+002). I believe they are occurring because regular pay isn't calculating correctly and the rest depend on that for their calculations. However, I can't see why regular pay isn't calculating correctly.

#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
class payroll{
ifstream fin;
char employeeid[100];

[Code] .....

View 14 Replies View Related

C++ :: Getting Error In Karatsuba Multiplication Program

Oct 5, 2014

I have made a Biginteger class that performs multiplication operation according to Karatsuba's algorithm. But it seems that the code is not working perfectly.In the class I have made a function named karatsuba(BigInteger a1, BigInteger b1)that performs the Multilplication operation. There might be problems in this function as I have tried to store the original digits(neglecting the leading zeros) of the two big integer values into two integers or there might be problems in somewhere else. corrected version of this function? My code is given below:

#include <stdio.h>
#include <iostream>
#include <cstdio>

[Code].....

View 2 Replies View Related

C/C++ :: Getting Error In Karatsuba Multiplication Program?

Oct 5, 2014

I have made a Biginteger class that performs multiplication operation according to Karatsuba's algorithm. But it seems that the code is not working perfectly.In the class I have made a function named karatsuba(BigInteger a1, BigInteger b1)that performs the Multilplication operation. There might be problems in this function as I have tried to store the original digits(neglecting the leading zeros) of the two big integer values into two integers or there might be problems in somewhere else.My code is given below:

#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
#define MAX_DIGIT 100

[code]....

View 5 Replies View Related

C/C++ :: Two Numbers Relationship Program Error

Aug 15, 2014

I write below two numbers relationship program and got below error.

//two numbers relationship
//take standard and console input and output
#include <stdio.h>
#include <conio.h>
//take function main
main()

//define numbers {
int num1; //first number
int num2; //second number

[Code] ....

View 3 Replies View Related

C++ :: QTCreator Finds Error Outside Of Program

Sep 20, 2014

Code:

#include <iostream>
#include <vector>
using namespace std;
struct Child;// incomplete type
struct Parent {
string name;
vector<Child *> children;// we don't need to know the details heres

[Code] .....

Why this program wont compile?

View 3 Replies View Related

C++ :: Compiled Program Error Win32 Invalid

Nov 30, 2013

I am using visual studio 2012 on windows 7. but, when I have compiled my programs and run them on an older pc to test out its functions, I receive an error saying that the program is not a "valid win32 application." I have even tested this with a very simple hello world console application, but the problem still remains. Where is the error coming from? is the application corrupted during transport? (upload to internet) or are programs compiled on win 7 incompatible with win xp

View 6 Replies View Related

C++ :: Insertion Sort Program - Runtime Error

Apr 11, 2013

I am trying to run this program for Insertion Sort, But some how I am getting some problem:

#include<iostream>
int main(){
int i,j,key,n;
scanf("%d",&n);
int a[n];

[Code] .....

Error
In function 'int main()':
Line 10: error: ISO C++ forbids variable-size array 'a'
compilation terminated due to -Wfatal-errors.

View 2 Replies View Related

C++ ::  Simple Encryption Program Runtime Error

Jul 22, 2014

I am trying to make a simple program for encrypting a char* with the XOR operator. The code compiles and links perfectly, but I get an Access violation runtime error:

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {

[Code] .....

Text that I am inputting:

My username is memberfunction.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved