C++ :: Creating Exact Age Calculator?

Aug 3, 2014

I've been wondering this, since there is so many things which needs to be taken care of. I created one, but it wasn't precise.

View 19 Replies


ADVERTISEMENT

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++ :: Creating Binary Calculator - Output Operation Of Subtraction

Feb 10, 2014

I need to create a binary calculator that outputs the operation of subtraction whenever you input 2 4 bit binary numbers. For example:

If I enter

1000
- 0111

View 1 Replies View Related

C# :: Creating Complex Number Calculator - Convert String To Ints

Sep 18, 2012

I am working on an assignment to create a Complex number calculator. In this assignment I am to ask the user for input to the calculator. We are given a sample run output that looks like this.

Enter operand1: 3 4
operand1: (3, 4)
Enter operation : +
Enter operand2: 1 2
(3, 4) + (1, 2) = (4, 6)

My question is how would I take from the user: an integer followed by a space followed by another integer and convert that into two seperate accessible int values that I can save as real and imaginary values.

View 4 Replies View Related

C# :: Run Program Using Exact Parameters?

Mar 19, 2015

im actually doing a authentication system, it will start console with

Username:

Password:

and do things but i want to know how can i give my program any parameters? i mean when im launching my program i want to do exactly this:

"C:UsersSpravcaDocumentsVisual Studio 2013ProjectsConsoleApplication14ConsoleApplication14inReleaseMyApp.exe" -registration

I tried to google "c# program parameters" && "c# program argues" but i couldnt find anything, maybe i just dont know how is exactly this named?

View 10 Replies View Related

C++ :: Coin / Money Change Code Doesn't Give Exact Change

Feb 20, 2013

My coin/money change code works when there can be an exact change each time, i.e. when the 1 cent option is available. However, when the change options are only $10, $5, $1, 25 cents and 10 cents, it does not give me what I want for instance, I wanted to get change for $237.80, I was expecting to get:

23 10's, one 5, two 1's and 8 dimes. However, the code below is giving me 23 10's, one 5, two 1's and 3 quarters (there is no option left for the 5 remaining cents).how to fix it?

Code:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void change(double cents, int a[]);
int main() {
double Dollars;
double cents;

[code]...

View 14 Replies View Related

C++ :: Write A Calculator Using Two Stacks

Apr 13, 2014

I just started by defining a stack class (stackDouble). I need to write a program that accepts an infix calculator expression, with the following operators (**, exponentiation, /, division, and, -, subtraction. The operator precedence is exponent, division, and subtraction.I need to use a stack of doubles and a stack of strings, of which I can write two classes, or write a single stack template. The user will input the expression just via cin, and there will be a # before every number, a ! before each operator, and a . at the end of the expression. '#', '!', or '.' can be input into a char variable, numbers into a double variable and operators into a string variable.

For example, the following would output 6:

# 3 ! / # 2 ! / # .5 ! ** # 2 .

As stated above, I already made up a stackDouble class. What would I need to do to create the other class (I don't think I want to do it with a template)?

Code:
#include <iostream>
#include <string>
using namespace std;
class stackDouble{

[code]....

View 2 Replies View Related

C :: BMI Calculator With Added Function

Aug 17, 2013

getting error with gcc under OSX.

Code:

/* bmi2.c */
#include <stdio.h>
main()
{
float height, weight;

printf("Enter weight:
");

[code]....

View 2 Replies View Related

C :: Calculator Using Mouse With A Bug While Dragging

Mar 6, 2015

I have an assignment to do a calculator in C, wich will work by clicking the numbers with the mouse, however i have a bug that when i hold the mouse and dragg it, it assumes that I'm clicking multiple times, also, when I click in an empty space the program creates a blank space on the calculator screen.

Code:

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include "..MouseHandler.h" // ajustar o caminho ao seu projecto
#include "..calcSkinLib.h" // ajustar o caminho ao seu projecto
#define PI = 3.1415;

[code]....

View 2 Replies View Related

C/C++ :: GPA Calculator With Text File?

Mar 5, 2015

I'm trying to create a program that will calculate the gpa of several different students, whose data are in a text file. The file looks something like this, with possibly more lines.

Mark 3 4 A 3 D 2 C 1 A
Tom 2 3 A 2 C

The very first number tells us how many credit hour/grades will follow. I have a couple of problems though: From the code I've written I don't seem to get any data other than the first line. Also the gpa that does print out after the file runs is just a 0.00, rather than the actual gpa.

#include<stdio.h>
int main(void)
{

[Code].....

View 6 Replies View Related

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 View Related

C/C++ :: Calculator That Uses Only Getchar / Putchar

Mar 24, 2014

I basically just have to make a calculator that only uses getchar/putchar (printf is Ok for displaying errors) - Also, negatives must be error-checked. As of right now, my program will only work if there is exactly one space between the number, operand, and other number. No spaces, or more than one space, will give me some very weird digits. I also need to display the numbers with putchar, and not printf (as I did below), but I just really wanted a working program.

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
int add(int input1,char operand, int input2);
int subtract(int input1,char operand, int input2);

[Code] .....

View 12 Replies View Related

C/C++ :: Area Of Triangle Calculator?

Nov 16, 2014

I was asked to build a small program to calculate the are of a Triangle but my code must have some problem.. />

#include "stdafx.h"
void main()
{
int a,b;

[Code]....

I get this errors:

-warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

-warning C4244: '=' : conversion from 'int' to 'float', possible loss of data

View 4 Replies View Related

C++ :: Calculator Using Pointer Does Not Work

Jan 18, 2015

I am making a calculator where I will input 5 array of numbers and calculate those numbers with pointers or whatever you call it. I am getting an error like

note C:Dev-Cppincludec++3.4.2itsostream.tcc:63 candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]

and more error if I try to fix the code. So yeah, can i have a hand?

Btw, here's my code.

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
using namespace std;
// function declaration:
void getAverage(int*);
void getSum(int*);

[Code] .....

View 7 Replies View Related

C/C++ :: Adding Calculations To BMI Calculator

Oct 8, 2014

I have to enhance my BMI program to tell whether the person is at optimal weight, under weight, or overweight and I cannot find the correct calculation. Here is the code I have so far that works for calculating the BMI.

namespace Body_Mass_Index {
public partial class BMI_HW : Form {
public BMI_HW() {
InitializeComponent();

[Code] ....

View 14 Replies View Related

C++ :: Make Different Type Of Calculator Out Of Boredom

Feb 10, 2014

ive been learning from the book for 4 days and decided to make a different type of calculator out of boredom but im really having problems when i try to make it a loop? ive been scratching my head trying to work it out rewriting deleting etc but cant work it out

Code: #include <iostream>
#include <string>
using namespace std;
int main()

[Code].....

View 9 Replies View Related

C :: Calculator - Input Specific Number?

Feb 11, 2013

In my calculator, I am trying to make it so that you put enter 1 to add, 2 to subtract, 3 to multiply, and 4 to divide. I am facing the issue of making it so that you must enter a number, however instead of it being any number, it must be 1, 2, 3, or 4, and if it is not any of those numbers, you must re-enter the number. Here is a little snippet of my code:

Code:

printf("Please enter 1 to add, 2 to subtract, 3 to multiply, or 4 to multiply: ");
while (scanf("%d", &input) != 1) {
while (getchar() != '
');
printf("Invalid option. Please try again: ");

[Code] ....

how I can make the loop affect specific numbers.

View 4 Replies View Related

C :: Calculate Equations Just Like A Standard Calculator

Oct 23, 2013

The main point of the program is to calculate equations just like a standard calculator but I wanted to do it myself. I don't understand what the problem is right now but I've managed to create a program that asks for both values but somehow it doesn't want to ask for an operator (*, /, + etc). What's wrong with my code that the terminal skips the scanning part for the operator?

Code:

#include <stdio.h>
int main() {
int value1, value2, answer;
char operator;

[code]....

View 12 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++ :: Generic Shape Area Calculator

Dec 6, 2013

I'm building a pretty basic calculator program that calculates the area of generic shapes (triangles, rectangles, and squares); for some reason though, my program is having troubles as soon as it hits the if/else code in the int main section. When I enter triangle, rectangle, or square, it just spits back out the "That's not one of the options. Please re-enter and try again." error line I created. When I isolate and run just the stuff inside the if/else statements it works great, but why it won't just understand my if (shape == triangle).... .

Code:

#include <iostream>
using namespace std;
class figure {
protected:
double x, y;

[Code] ....

View 2 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++ :: Simple Calculator - Result Will Always Equal Zero

Jan 21, 2014

I'm making a simple calculator and have done it all right where you can input everything, all the functions are there, but when i run the program it will come to displaying the result and it will always equal zero, I just need it to say 8+8 = 16 rather than 8+8 = 0, i don't know whether its just displaying the results as 0, or not displaying it at all, the code will follow below:

Code:

#include<iostream>
using namespace std;
double num3;
double num2;
double result;
char operation;

[Code] ....

View 4 Replies View Related

C++ :: Layout Design Matrix Calculator

Aug 26, 2013

I want to ask on how to put a layout design in the program when it is being ran. It should look like these: [URL] ....

This is a sample code:

#include<iostream>
using namespace std;
main() {
int m, n, c, d, first[10][10], second[10][10], sum[10][10],
minus[10][10], times[10][10];
char ans;

[Code] ....

View 2 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++ :: Bitcoin Calculator - 40 Billion In Variable

Dec 3, 2014

I'm trying to do a bitcoin calculator, however I can't get the difficulty (40007470271) to any variable

uint64_t diff = GetDlgItemInt(hWnd, IDC_DIFF, NULL, TRUE);
uint64_t speed = GetDlgItemInt(hWnd, IDC_SPEED, NULL, TRUE);
uint64_t price = GetDlgItemInt(hWnd, IDC_PRICE, NULL, TRUE);

stringstream ss;
ss << diff << " - " << speed << " - " << price;
MessageBox(hWnd, ss.str().c_str(), NULL, NULL);

diff returns 0, even when I just do GetDlgItemInt to the stringstream it's 0, how should I somehow save the variable so I can use it in calculation?

I also tried getting value as a text and then converting it to 64bit int, but I'm getting some weird number, over 300 Billion...

int len = SendMessage(GetDlgItem(hWnd, IDC_DIFF), WM_GETTEXTLENGTH, 0, 0);
string str;
GetDlgItemText(hWnd, IDC_DIFF, (char*)&str, len+1);

[Code] ....

View 15 Replies View Related

C++ :: Relativistic Effects Calculator - If Statements

Mar 11, 2014

So I recently took on the task of making a 'Relativity Calculator' and am Having a trouble with some if statements. Here is the code.

// This program is designed to tell a user the Relativistic Length, mass and time of something going a certain speed under c

#include<iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;
int main(){
char choice; // User's choice
float c; //Speed of light

[Code] ....

My problem is that it says A, B, and Y are not defined, and theyre not, I have them set up so the user inputs them. But when I do put them in as char, The program compiles, but does nothing after i input A or B.

View 2 Replies View Related







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