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


ADVERTISEMENT

C :: Calculator Doesn't Compile - Not Printing Result

Mar 16, 2014

I'm new to C, and I'm trying to write a program that gets a string, divides it into terms and operators, reduces them and prints the result. I know the source code doesn't do exactly that, yet (specially the last part), but I'd like to compile it.

Code:
#include <stdio.h>
#include <string.h>
int main ()
{
/* Write a welcome message. */
printf ("
Calculator

I use Bloodshed Dev-C++ with Ming-W and I get quite a few errors when I try to compile it.

View 6 Replies View Related

C/C++ :: Simple Polynomial Derivative Calculator

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

C++ :: Simple Calculator - Press A Key To Continue

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

C++ ::  Simple Program To Prepare Result Of N Students Using Structure

Jan 17, 2014

This is the program below..can you spot the errors in it.. I am getting lots of errors...!!

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct student {
char name[10];
int rollnumber,result
float m1,m2,m3,total

[Code] .....

View 12 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/C++ :: Simple Calculator - Clear Screen Following User Input

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

C :: Simple Multi-Session Calculator / Switch Case And While Loop

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

C++ :: Calculator To Gives Result Of Roman Numerals In Roman Mode

Dec 5, 2013

About exercise 7 of chapter 10 of PPP (page 372): changing the calculator to gives us the result of the roman numerals, like XXI + CIV = CXXV.

At *first* time there are two solutions for solving it in my mind.

First is, giving each roman number to a function like the one existing in exercise 6 and then get their integer numbers and then calculate them by the calculator of chapter 7 and finally make a function to convert the result to roman mode. (simpler)

Second is to change the calculator from chapter 7 to calculate roman numbers inside itself and gives the result again in roman mode. (harder)

As an important step of ‘solving the problems’/’programming’, how can I make decision to choose a solution for solving a problem.

View 8 Replies View Related

C/C++ :: Replace Value With The Variable That Is Equal To It?

Sep 10, 2014

i would like to know how to replace a value with the variable that ii is equal, i mean like a=5 i want to be able to replace the number 5 by the letter a when needed in printf. ofc i want to use this for an actual purpuse and meaning what i gave was a mere example and thxx. BTW DONT jUst DROP a few lines of code that would make it work

View 5 Replies View Related

C :: Finding Equal Values In Array

Feb 3, 2015

How i can find two equal int in array with O(n) time complexityand O(1) place complexity?

View 8 Replies View Related

C :: Function To Search If Two Given Strings Are Equal

Jul 9, 2014

I made my own function to search if two given strings in my function are equal but the problem is if i pass two variable like hello,hello ... result is string equal but if i pass hello , hello also give me string equal because last 4 characters same to last 4 characters of hello ...

Code:
int getSimilarityOfTwoStrings(const char str1[],const char str2[]){
int str1Len = getStringLength(str1);
int str2Len = getStringLength(str2);
int i = 0;
int j = 0;
bool truefalse;

[Code] .....

View 3 Replies View Related

C++ :: Terminate Loop When Two Integers Between 1 To 100 Are Equal

Mar 21, 2013

creating a program using while that terminates the loop when two intergers any two between 1 to 100 are equal with each other

View 2 Replies View Related

C++ :: Limit Number Of Flottant To Get Equal Numbers?

Feb 26, 2014

I calculate two numbers "R1",R2"

when i make
cout<<R1;
cout<<R2

i get
R1=51,9151
R2=51,915

when i make

Code: if (R1>R2) cout<<"i am here" he print the message

but they are equal. how i made limit the number of flottant to get equal numbers?

View 13 Replies View Related

C++ :: A Program To Find All Pair Of Numbers Between 0 And N That Equal K

Oct 29, 2013

int main()
{
int a=0, c, d, N, K;
bool stopBool = 0;

[Code]....

This is supposed to find take a number N and K and find all numbers between 0 and N that equal K and cout the number of pairs that fit it but it doesn't work.

View 2 Replies View Related

C++ :: 2D Vector Check If Index Equal To Null?

Dec 2, 2014

how to check if a specific index equal to null when i try to implement it, it gives an error for example:

vector < vector <double> > v;
v[0].push_back(0);
v[0].push_back(1);
v[0].push_back(2);
v[0].push_back(3);
v[1].push_back(10);
v[1].push_back(11);
v[1].push_back(12);
v[1].push_back(13);
if(v[0][4]==NULL) {
cout<<"empty"<< endl;
}

View 1 Replies View Related

C++ :: Program Which Print Out All Prime Numbers Less Than Or Equal To Given Number

Nov 11, 2013

how to make a programm in native c++ which print out all prime numbers less than or equal to given number????????

View 5 Replies View Related

C/C++ :: Programs Keeps Producing True - No Matter If Two Numbers Are Equal Or Not

Sep 25, 2014

In my program I am supposed to call isEqualTo with a user defined class type, and print out if my two numbers being compared are equal or not. I had to write two versions of this, one with just a template which works fine, but when I implemented the class, all the sudden my program just spews out true no matter if actually equal or not. Here is what I have so far:

#include "stdafx.h"
#include <iostream>
#include "UserClass.h"
using namespace std;

template<typename T>
bool isEqualTo(T value1, T value2){
if (value1 == value2)

[Code] ....

View 4 Replies View Related

C Sharp :: Split A File In Equal Size According To Its Bytes

Apr 10, 2013

how to split a file in equal size and when clicking on split button it split the files as well as encrypt split parts and the size information are automatically stored in groupbox and save all splitted files in folder.

View 1 Replies View Related

C :: Set Variable Of Type Char Equal To Element In Array Of Characters

Mar 3, 2014

I am trying to set a variable of type char equal to an element in an array of characters. For example:

char data[4] = "x+1";
char element;
element = data[2];

This seems like a logical progression from number arrays, but when I print both element and data[2], I get data[2] as expected, but element gives a different character every time (I assume a garbage value).

View 5 Replies View Related

C++ :: User Input 10 Integers Of Array - Add Numbers Greater Or Equal To 10

Oct 29, 2013

create a program that asks the user to input 10 integers of an array the program will add the numbers greater or equal to 10.

View 6 Replies View Related

C/C++ :: Delete From Sentence All Words With Character Count Which Is Equal To Pair Number

Nov 20, 2014

I have an assigment to make program which deletes from sentence all words with character count which is equal to pair number , for example - [ I like C ] and the result of this program should be [I C] because the word like contains 4 characters which is pair and it should be removed.

So I started writing my program and I am stuck at this block of code -

#include <stdio.h>
#include <stdlib.h>
main () {
char text[100], blank[100];
int c=0,d=0,i,j;
gets(text);

[Code] ....

To explain what is happening - I go through all string and search for first ' ' space symbol and check its value. If it is pair then my program prints that it is not pair[because last character before space had not pair number of characters], but the hardest part comes in when i have two not pair words , because space takes one character and now when i check if i%2 == 1 the answer is false [0] for the second word .

View 2 Replies View Related

C# :: Making String Equal Many Different Values Then Compare Those Values

Dec 18, 2014

I was wondering if this was even possible and if so, how do I do it.

else if (speech.ToLower().Contains("truck") && speech.EndsWith(number))
{
Here I would like to see if my speech had ended with any of the values i would have stored in the string "numbers". If it did, I would like to just take the value and add it to a new string called whatever
}

I have tried this a million different ways and I cant get it to work. I'm not even sure how I would go about storing tons of different numbers in one string, or if that's even possible.

View 10 Replies View Related

C :: How To Get Upper Case And Lower Case Equal

Feb 18, 2015

I just dont know how to get my upper case and lower case equal...heres the program: Write a program to calculate utility cost for ACME UTILITY COMPANY. The company has 3 types of customers (R) residential, (C) Commercial and (G) government. Customers are billed based on the number of kilowatts used and they type of customer they are (R,C,or G).

Residential cusstomers are charged 0.25 cents per kilowatt hour for the first 500kw used, and 0.35 cent per kwh for all kw used over 500.Commercial customers are charged 0.22 cents per kilowatt hour for the first 999kw used, 0.29 cents per kwh for all kw used over 999 kw up to 1999 and 0.45 cents per kwh for all kilowatts used greater than 1999. Commercial customers that use over 2000 kw are charged a special surcharge of 100.0 in addition to the regular charges.

Government customers are charged 0.34 cents for the first 1500 kwh used(<=1500). 0.30 cent for the next 1000 kwh(1501-2500) and 0.25 cents for all kwh used over (>=2501)

in addition residential customer are charged .5% tax on the cost utilities while Commercial customers are 5% tax on the cost of utilities not including the special surcharge Government customers are not charged a tax

Code:

#include <stdio.h>
#include <math.h>
int main(void)
{
int R;
int ct;
int kwh;
int taxes;
int surcharge;
int charge
}

[code].....

the program should quit with Q and calculate the amount owed, utility charge, and surcharge

View 8 Replies View Related

C :: Not Getting Required Result

Apr 30, 2013

Code:
void search(){void output(void);
char title[20],;
char *p;
clrscr();

[Code] ......

Info:Program that stores information about reports .the above function searches the report according to its title. list is the name of the structure that stores the records.

Why i'm using strstr:

for eg. there is a report titled 'report on tigers'

I want the report information to be output if someone searches for 'tiger'

Output:displays all the entries i have made till now

file is attached.

View 4 Replies View Related

C++ :: How To Pass By Value-Result

Dec 4, 2014

I'm trying to understand the pass by value-result. The code I have came up with so far only does by value and by reference, which I understand. The value-result is what has me stumped, and honestly I am unsure how to write the function for it. Here's my code so far...

#include <iostream>
using namespace std;
// Function prototypes.
void swapByValue(int, int, int);
void swapByRef(int&, int&, int&);

[Code] ....

View 4 Replies View Related







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