Now why does defining the if condition as if(pow(i,2) + pow(j,2) == pow(k,2)) doesnt work (ie. doesn't print anything) while defining it as if(i*i + j*j == k*k) works flawlessly - by working I mean printing out single set of 3 numbers.
The while loop part of my program isn't working right. stringOriginal is an array. If a large amount of characters passed the max 80 im processing is typed, it goes into a infinite loop. Also the condition doesn't work i type in quit and the loop continues.
while(stringOriginal != "quit"){ std::cout << "Enter a string of characters you would like to reverse "; cin.getline(stringOriginal,79,' '); }
I need to do make a loop inside a condition. Can it be done? I don't want to call another function to do it. Any way at all without calling separate function inside the if? I just want to do:
if ( for (int i = 0; i<=10; i++) { //stuff related to the for loop } ) { //stuff related to the initial if condition };
I'm writing a delete function for a linked list, and I'm having issues with this bit of code:
void deleteNode(int data){ node* del = NULL; t = h; n = h; while(n != NULL && n->_data != data){ t = n; n = n->next; } }
Or more precisely, this portion:
&& n->_data != data
n is my new node variable, _data is the storage variable in the private section of my class, and data is the information being searched for that needs to be deleted. Everything works without this section of the code. My assumption is that n->_data is somehow wrong, but I don't see how. I've tried everything I can think of- using parenthesis, using the variable rather than the pointer, I've tried expressing the pointer in a different way, I've tried using my t variable rather than n, and I've found examples online that use this exact same expression without any issues.
Write a program to calculate the Loan Balance, where a person borrows an amount A and in return he/she agrees to make N payments per year, each of amount P. While the person is repaying the loan, interest will accumulate at an annual percentage rate of R, and this interest will be compounded N times a year (along with each payment). Therefore, the person must continue paying these installments of amount P until the original amount and any accumulated interest is repaid.
NOTE: The formula to calculate the amount that the person needs to repay after T years is-
Balance Amount after T years = A[(1+R/N)^NT]-P -----------------------------------------------------------
I have a few doubts :
1. I think that the "balance amount" formula can directly give the "loan balance" for the person. I'm not sure if it's correct but in that case the question would serve no purpose. Maybe I'm wrong.
2. If there should be a loop to calculate the loan balance, what condition should I give and which loop will be better to use?
I wanted to input some numbers with scanf function, i can enter some numbers and if I input -1 to the scanf, the input must end. And the scanf function has limited input, the max that I can input is 40 numbers.example if enter 1 2 4 6 5 4 -1 the scanf function will ended and the result will be appear.I wanted to know how the scanf function is like that would be best for this problem, Code: scanf("%d", &n); the result if I input those number will be like
This of course is not the right way to write it. How to generalize it so that I can check the condition not only till 20 but till any number without manually adding all conditions.
I am try to make a menu for deliver order program.
The menu divide into 3 group which are breakfast, lunch and dinner. However breaker only available at 6.30am-10pm, lunch available at 11am-1.30pm and dinner only available at 6.00pm-8.30pm
Let say my current time on the system is 10.30am, and the user select breakfast order. It should not available at this time, and prompt a message to use that the order not available at this period.
I have two table the first is called Imprrests and the second is called ]IprestsPays. There is an Imprest_ID column that is primary key in [icode]Imprests[/code] table and foreign key in ImprestsPays table
Imprests table consists the following columns: Imprest_ID, Impres_value, Imprest_date, Employee_ID
Where Employee_ID column is primary key in Employees table and foreign key in Imprests table.
ImprestsPays table consists the following columns: ID, Payment_value, Payment_date, Imprest_ID
My problem is in the buttonadd_click event in Imprsts form.
I want to prevent user from insert any new imprest for employee in Imprests table if employee haven't paid all payments in ImprestsPays table for old imprest...
I am trying to write a simple program that produces different outputs based on entered age of two different users. Program should tell who is older and behave different if both users are older than 100.
Here is my program: Code: #include <iostream> using namespace std; int main() {
[Code].....
Why program executes this when both users are obviously more than 100
I'm trying to get an if/else statement to work using a character condition, but it is a no-go. After I input either a 'y' or 'n', the program just sits there until I press 'Enter' again, at which point it ends. It never actually goes through either of the 'if' statements. At first I only had a single '=' in the condition, but I found that that was wrong. When I corrected it to '==' it still didn't work. I also tried clearing the buffer by adding a 'getchar()' at the beginning of the program, but that didn't work either.
The compiler (Visual Studio 2013) requires me to use 'scanf_s' instead of just 'scanf' for some reason, and if I don't have two 'getchar()' commands at the end, then it won't stay open long enough for me to see the results.
I have always written like a>='0'&&a<='9'&&a>='a'&&a<='z' in loops etc, but no more. Basically add whatever you want to condition, and if you want point a to point b just separate them with a '-' sign. Simply
I'm parsing a text file, and I'd like to detect when a certain Compilation Condition - i.e. #ifdef - begins. The challenge is, that the condition can take any of the following patterns:
#ifdef (FLAG) #if defined (FLAG) #if (defined (FLAG))
(And perhaps I missed more)
I'd of course need to treat them all the same, as they are indeed the same. How would you know to treat them all the same?
I am trying to implement a Task scheduler where i have n number of tasks. The Idea behind my task scheduler is that in a loop of queues of a vector, task should get enqueued to the shortest queue among the loop of queues, which is done by the following code.
#include <vector> #include <queue> std::vector<std::queue<int> > q int min_index = 0; task t // implemented in the other part of the program
[Code] ....
Next i am trying to extend this paradigm to reduce the overhead time of the scheduler, Instead of searching the shortest queue every time, search after some condition ie. search the shortest queue after 5 tasks gets enqueued to the shortest queue.
i need to do something like this
#include <vector> #include <queue> std::vector<std::queue<int> > q task t // implemented in the other part of the program while(q[min_index].size()!=q[min_index].size()+5) // check whether current min_index queue's size is increased 5 more times if not goto enqueue
We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.
I have tried to submit this topic before but i didn't submit my whole code and it was removed. So here it is. All I am trying to do is load form2 from form1 then back to form1 from form2 for a certain number of times the get out of the loop. I am new to C-Sharp and it seems as though I cant seem to figure out a way to do this.
Here is form1 and form2 code. I have commented out a few things I have tried.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
I already made a nested for loop into a while loop (below this) and now I'm trying to make the outer for loop into a do while loop, but it's not working.
#include <iostream> using namespace std; int main () { int len; int j; int i;
[Code]....
And I can't make this code do the same thing. It stops after one loop, instead of continuing to the end. Why won't the loops continue?
#include <iostream> using namespace std; int main(){ int len; cout << "Enter a number: ";
I for the life of me can't get my logic straight. I have 2 lists, 1 a list of text, and the other a list of int.
Here's my main list: List<string> ListNeedToADD = ListOfSPSExt.Except(ListOfReportExt).ToList(); Here's my second list:IEnumerable<int> result2 = Enumerable.Range(1, Convert.ToInt32(myValue)).Except(hostList);
I need to loop through my main list, ListNeedToADD, and for each item in that list, grab 1 value from the 2nd list and send those 2 items to a method. Something like this:
The problem with doing it the way I am above is it loops through ALL the items for each myString.
For my method, it needs to look like this: insertReportLimits(attribTable, "34257", 22, con); then it would move on to the next: insertReportLimits(attribTable, "34854", 27, con); etc etc.
I can't get out of my loop to fill the array. This array should stop and print after 10 inputs. but it keeps asking for input.
This is what my code is supposed to do. Use 0 as sentinel for an array. Only positive ints will be entered into the array. A negative int should result in an error message, then input will continue. The numbers will be inserted into the array in ascending order. Do not insert them then sort the array.
#include <iostream> #include <cmath> using namespace std; const int arraySize =10;
I am using a for loop to count down from 10 to 0 it's working to count down from 10 to 1 but when the program cames to the 0 then the program freezes by any reason.
Code: #include <iostream> using namespace std; int main() { int number[2]; cout << "Enter number: "; cin >> number[0]; if (number[0] == 1)