Is there a simple notation to check if a value is within a plus or minus range?
E.g.
//I read a value A. delay(50); //Read value again -calling this value B delay(50);
//Read value again -calling this value C delay(50); //Read value again -calling this value D delay(50);
//Read value again -calling this value E
Check IF first value A is within 5 of the value B and within 5 of value C, etc.
I can think of a few round about ways of doing this but is there any simple "equals to plus or minus" notation? (what I actually want to do is to check a lot more values than this and it will get very complicated with any of my solutions)....
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)
It is showing error because may be I was not able to put that if statement inside any function. find out the error sand complete the program with corrected code.
I'm creating a bank system. So I know to make a deposit to the balance, which add ups what is the balance to i have add.
When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.
double deposit(double balance){ double addSum = 0; system("CLS"); cout<< "Welcome to deposit."<<endl; cout<<"Enter a sum you wish to add to your account:";
[Code] .......
When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0
When i make another withdraw from example -150, it will be -150.
Which shows correct.
But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.
double withdraw(double balance) { double takeSum = 0; system("CLS"); cout<< "Welcome to withdraw."<<endl; cout<<"Enter a sum you wish to take away from your account:"; cout << balance << '
[Code] .....
What is causing this problem, also when function deposit and withdraw close, it goes to readBalance function, should go to menu.
double readBalance(double balance) { int option; system("CLS"); cout<<"Welcome to balance."<<endl; cout<<"Your balance is:"<<endl;
So I know to make a deposit to the balance, which add ups what is the balance to i have add.
When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.
Code: double deposit(double balance) { double addSum = 0; system("CLS"); cout<< "Welcome to deposit."<<endl; cout<<"Enter a sum you wish to add to your account:";
[code]...
When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0 When i make another withdraw from example -150, it will be -150.Which shows correct.
But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.
Code: double withdraw(double balance) { double takeSum = 0; system("CLS"); cout<< "Welcome to withdraw."<<endl; cout<<"Enter a sum you wish to take away from your account:";
T minus 10 and counting T minus 9 and counting T minus 8 and counting T minus 7 and counting T minus 6 and counting T minus 5 and counting T minus 4 and counting T minus 3 and counting T minus 2 and counting T minus 1 and counting
Declare the following index before the while loop:
int index = 10;
Correctly code a while statement below using the variable index as defined above, to produce the output shown above.
So this is what my code looks like... I also have to convert this same loop into a do while and for loop. So if I can get this one right I think the others should come relatively easy.
while (int index >= 10) { cout << "T minus " << index; index--; }
I have same question as posted by holla and Iam not sure about merging the contents of 2 sorted arrays into another array without duplication of values.
I just wrote code that is a program for a relativity calculator. However many of my outputs (because the values tend to be large) end up in scientific notation. Although useful, its not great for the laymen, or nice looking.
How can I change it so that output is not in scientific notation? here is the code:
// This program/converter is designed to find the desired 'real' values using Einstein's theory of relativity
Ex. 5 4 + 3 10 * + the answer is 39 because if I change it to infix, it's (5 + 4) + (3 * 10)
I need to use vector to compute the value. Here is what I think. First, I save leftmost from the string. If it is a number, I push. If that is a operation, I pop twice and push the result. By doing it until the string is emptied, the vector will only contain the final answer. And here is my code
#include <iostream> #include <vector> #include <string> using namespace std; int main(){ vector<int> stack; string input;
[Code] .....
When I put 1 1 + or 2 2 +, it showing me a correct answer, but when I put the above example which is 5 4 + 3 10 * +, it shows 30 instead of 39.
I'm trying to make an infix to postfix notation calculator. The difficult thing is th stack class is custom. It's not to hard to understand, I don't know if the fact that it is that way will not allow me to receive support. The difference is that the pop functions is as such:
stack<char> conversion; char temp; conversion.pop(temp);//It receives a parameter and puts the popped element in there. conversion.peek(temp);//Places the top element in said parameter
not only that... but these are boolean functions. they return true if the operation was completed. So they can be used as conditions.
#include<iostream> #include<string> #include<stdio.h> #include"stack.h" using namespace std; int main(void) { Stack<char> conversion; string infix,inter,temps;
[Code] .....
The error is that i am mismanaging parenthesis handling and i can't seem to grasp where and how.
An example input is:(35+7)-(9-2) that input gives me:35 7 + 9 2 ) - but another input such as :(35+7)/7 outputs as: 35 7 + 7 /. Totally fine.
double number = 10000000; int range;//the length of the string result string result;//holds the number in a string ostringstream convert; //stream used for the conversion convert << number; result = convert.str();
range = result.length();
I'm trying to convert a double to a string and when the number goes to ten million it goes to scientific notation and it shows it in the string. How do I stop it from do that?
I was trying 2 write a program that would calculate the sum notation of 1/(i^2) with the starting number to be 1 and goes up to the nth term. For instance if the user inputed 3 then the sum would look like 1+1/4+1/9. I somehow made a code but it gets weird numbers which some include negative numbers... when I input a number that is above 5.
#include <stdio.h> #include <math.h> int main(int argc, const char * argv[]) { int n; register int i=1; float b;//For part 1
[Code] ....
For some reason I can't edit printf("%f",/>/>; when I post it as the topic so ignore that part cuz Ik its supposed to be written as printf("%f",/>;
My code compiled well(After long Messing up with my head). But, i still not satisfied of my output as i expected. My code ought to sort the object of person comparing their salary. But, its not.
Code: #include <iostream> #include <string> using namespace std; class person { protected : string name; float salary;
[Code] ....
It doesn't sort the object of class person rather than it prints out the stored value as it is.
I have this code in order to make a RPN calculator,but im trying to read from the console entering the expression in reverse polish notation,Also I think it will be better to use fgets() instead of scanf since the person can entere something like this 3 2 1 + x
I'm writing a program to calculate a final grade by adding 4 numbers minus the lowest grade and dividing by 3. My knowledge in c is not extensive I thought that a simple assigment operator would do the job but I'm getting a strange large numbers in the execution.
I have an std list of type double.. and the list is always guaranteed to have just 2 elements. I need to get the value of element 2 minus element 1. What is the least amount of code to accomplish that?
I tried this:
Code: list<double> dList; dList.push_back(1.0); dList.push_back(2.0); list<double>::iterator iter = dList.begin(); list<double>::iterator iter2 = dList.end(); double result = *iter2 - *iter;
I was having problems changing the value of my head node I passed it as an argument as head which would be the address. The parameter was defined as struct node *head. like this
I tried manipultaing pointer values to change head node value but it did not work. I saw some code online which used pointer to pointers(in code below) to change head node value it worked I dont fully understand why. Would like better understanding of why.
Would also like to know why the argument call needed &head instead of just head.
remove = deleteNode(&head,found); opposed to remove = deleteNode(head,found);