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
ADVERTISEMENT
Feb 25, 2013
I can not understand huge pointer, how its working.
#include<stdio.h>/ *How its working &decleration*/
int main(){
int huge *a =(int huge *)0x59990005;
int huge *b =(int huge *)0x59980015;
if(a == b)
printf("power of pointer");
else
printf("power of c");
return 0;
}
View 4 Replies
View Related
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
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
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
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
View Related
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
May 14, 2013
I am working on a project which is a fairly simply BAC calculator. I am attempting to grab data from a text file, which contains state abbreviation, maximum BAC before aggravated, and minimum license suspension. The text file looks like
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <stdio.h>
#include <ctype.h>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <sstream>
using namespace std;
float MALE_RATE = 0.68, FEMALE_RATE = 0.55, LEGAL_LIMIT = 0.08;
//percent of body weight which holds alcohol
[Code] ....
The code I am struggling with is the getline and stringstream which is near the bottom.
The output I am getting is
The maximum BAC before aggrevated DUI in AL is .15
The minimum penalty in AL is 90 day suspension of license
I get that for every state I type. I know it is reading the first line, but something in my code does not allow it to read the other lines
View 1 Replies
View Related
Jan 31, 2015
I'm working on an assignment where the user inputs the center coordinates(x,y) for an circular array of (x,y) points. The program performs some calculations, then outputs the position of each point, based on the diameter and center location.
The issue I'm having is that the number of points is a variable(inputted by the user). How to make the program perform the calculations for a different number of points each time.
Code:
// Bolt position Calculator
// Calculates position of bolts on plate using number of points, hole diameter, and (x,y) coordinate of center
#include<iostream>;
#include<math.h>;
#include<cmath>;
#define PI 3.14159
using namespace std;
int main() {
int n,xn,yn
float D,x,y,A;
[Code] ......
View 2 Replies
View Related
Feb 11, 2014
math part.
The equation I need to use is: payment = [(rate * (1 + rate)^number payments ) / ((1 + rate)^number of payments -1)] * loan
Also, the value of rate in the above equation is (interest/12)/100. So 12% annual interest would be 1% monthly interest.
heres my code:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
[Code].....
View 4 Replies
View Related
Jul 5, 2014
Write a program which is used to calculate the GPA based on the grades for different courses input by user. User should be able to use this to enter grades for as many courses as he wants unless he wants to quit. (you may consider using some loop). Once user has completed entering of data, the program should be able to provide a feedback to the user about the GPA. A is equal to 4, B is equal to 3, C is equal to 2, D is equal to 1, rest are 0. Use minimum 5 course to demonstrate working of your code.
Here is an example (User input is in italic and bold):
Would you like to enter grades: Y
Please enter the course name: COSC1301
Please enter your grade: A
Would you like to enter more grades: Y
Please enter the course name:ITSE1301
Please enter your grade: B
Would you like to enter more grades: Y
Please enter the course name:ITSE2409
[code]....
View 4 Replies
View Related