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
ADVERTISEMENT
Jan 16, 2013
I am currently working with win32 API , for image processing, one of the windows function returns RGBA ( colors ) as unsigned int , I then split it into individual bytes by creating a union ,
Code:
union colour {
unsigned int value;
unsigned char RGBA[4];
}
to spit the int into individual bytes, my Question is there a better or my convenient way of doing this.
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
Feb 27, 2014
So I'm trying to make a derivative calculator that can do simple polynomial calculations in a very specific way. If you read the cout line you'll understand rather quickly.
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
using namespace std;
struct variable {
char Variable,degree,constant;
[Code] ....
I get an error at line 33 and 37 saying error: request for member '_cstr' in 'constant', which is of non-class type 'char'
and the same line with 'degree' instead of constant.
View 2 Replies
View Related
Apr 20, 2015
My problem is , i want to make a simple calculator , in the console i want afterall the user to choose what type of operation he want pressing a key like i mentioned in the title the keys would be F1,F2,F3 , i'm not finding in the internet the code to the detection of a press key like what i want.
Code:
#include <iostream>
using namespace std;
int F1 (int x, int y) {
cout << "Enter a number: " << endl;
cin >> x;
[Code] ....
View 7 Replies
View Related
Dec 10, 2014
I am working on a simple calculator in C++ .... All works fine with the calculator up until the requirement for the user to input "do you want to go again y/n" .... What i want to happen is the screen to clear down and reloop to the enter name part....but i can't get it to do that
Program Description: To write and develop a programme where a user can input a cost or price of something before VAT our program must then process the input number and must output the price with the original value plus VAT
#include <iostream>// I must use this to start my programming
#include <string> // I have added this for the extension task so the user has to input their name
#include <iomanip> // this is to manipulate the text
#include <stdlib.h>
using namespace std; // using the "using namespace std" shows that i will be using standard text throughout this programme
[Code] .....
View 5 Replies
View Related
Jun 30, 2013
I have a problem with my simple operations calculator code (using C, in Code::Blocks). I am required to use a while loop statement so the user can execute multiple step operations without re-opening the program. When I launch the program, I get through the first session fine, but when I'm on the second session, when entering the two operands and press enter (to calculate), it just gives me the return and say press any key to continue (exit).Here is the code:
Code:
# include <stdio.h>
int main()
{
int num1, num2;
char op;
int finished = 0;
}
[code]....
View 8 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
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
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
May 11, 2014
My address book will be simple, and the thing's that I'm expecting to use in it are :
Pointers, Linked Lists
Malloc
Structs
Typedefs
Makefile, header file
Putting functions into different program files
I have started the program trying to create a struct, and getting it working with a couple of entries before going onto user input and splitting it up.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
// Struct type address book. Just a name, a number and a pointer
[Code] .....
I'm a bit lost at this point... My knee jerk thought is to create a for loop, and cycle through the list.
I'm not sure how this would apply to this though? Without using the familiar type of print loop such as :
Code:
for (i = 0; ;i++) {
printf("%i
", array[i];
}
I'm thinking that I need to create a temporary struct that can be used to assign the value of the next struct in the list, and then somehow print from that....
I'll try and write the logic out :
while temp != NULL (The last node value is assigned NULL to show us where the end of the list is)
create a temporary pointer that can be used to keep track of where we are in the list.
print out the current entry name and number
then assign the temp pointer value to the * next of the current struct. So if we are in entry1 the *next should be the address of entry 2.
Print out entry 2 name and number, assign entry 2 next to the temp value.
View 1 Replies
View Related
Dec 4, 2012
how to split a child window in an MFC MDI program.
Splitting Child Window in MFC MDI Program
[URL]
For my purposes, this achievement is practically useless because I cannot find a way to pass text from one CRichEditView window to another.
Given two CRichEditView windows, CInputViewView and COutputView as child windows in an MFC MDI app, my goal is to capture text in the former and print that text in the later using a button click.
Using what appeared to me to be a logical way to proceed, I tried variations of the following code:
Code:
void CMainFrame::DoSomething() {
//MessageBox(_T("Like What ?"), _T("Do Something"));
//CInputViewView * pin = (CInputViewView*) GetActiveView();
CInputViewView * pin = (CInputViewView*)m_wndSplitter.GetPane(0,0);
pin->GetWindowTextW(m_csDisplay);
[Code] ....
None of this works and even the attempt to access the pane results in an app crash in winsplit.cpp.
Code:
#ifdef _DEBUG
void CSplitterWnd::AssertValid() const {
CWnd::AssertValid();
>ASSERT(m_nMaxRows >= 1);
//..
View 4 Replies
View Related
Oct 30, 2014
I currently have a running program "game.cpp" that runs a game of tic tack toe. I want to split the working functions into header files so that game.cpp isn't so cluttered. I have created two header files "displayBoard.h" and "gamePlay.h" but they wont compile because the functions are looking for variables that haven't been declared. First, here's the working code.
#include "displayBoard.h"
#include <iostream>
#include <limits> //This is required to catch invalid user input
class ticTacToe //A class to contain all our functions {
[Code] .....
View 11 Replies
View Related
May 29, 2014
I am trying to create n number of files (n being an integer), by passing the name through a character array (and obviously changing its value at each iteration). But the problem is that the program compiles and executes but not a single file is created.
Here is my code snippet.
void file_phipsi(int m)
{
int a=0,n=0;
char *str1;
[Code].....
View 4 Replies
View Related
Feb 22, 2014
I can't get c++ compilers to create or open files with a string input, even though the compiler accepts a file name in "quotes". How can I get this compiled (I am downloading a series of file names which I need to load into a consolidated file).
My coding (the commented line works, the string example does not).
//indirect file open example
#include <iostream>
#include <fstream>
#include <string>
[Code].....
View 4 Replies
View Related
Oct 27, 2014
I'm supposed to read in a data file with fixed length records and fields, create a sorted index list in memory, and save that list to a file. Then I'm to write a second program that interactively (via the Linux command line) takes a key and the index file name, opens and loads the index file, searches for the given key using the index table, and opens and returns the correct data record.
The original file consists of a list of records with a key (int), a name (string of 8 characters max), a code (int) and a cost (double).
The RRN (relative record number) begins at 1, with the RRN at 0 representing a dummy record with only the size in the first entry.
Here is the data file I will be using.
8 blank 0 0.0
12345 Item06 45 14.2
12434 Item04 21 17.3
12382 Item09 62 41.37
[Code]....
The "File is Open" part will be replaced once I figure out what do do once the file is open, just used this message to verify that it was opening the file.
View 12 Replies
View Related
Jun 23, 2014
I'm currently trying to create binary file will not be able to be read as texts and will contain metadata(more like image files).
But I've tried writing to .dat, .bin files in binary mode and all of them are displaying in ascii text..which I don't want.
View 3 Replies
View Related
Apr 5, 2013
I am writing a program to hide files behind other files using Alternate Data Streams in Windows NTFS file systems.
The program is as follows:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void){
char hostfile[75], hiddenfile[75], hiddenFileName[15] ;
printf("Enter the name(with extension) and path of the file whose behind you want to hide another file: ");
scanf("%75s", hostfile);
[Code]...
The complier is showing error as "Extra Perimeter in call to system" but I am not getting where?
View 4 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
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
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
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
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
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
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
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