Hi Guys,
Can you have a browse through my code and see if you can see a problem.
The problem i am having is, when i enter the second number and validate it as wrong ie, more than 6 digits it returns to begining asking for the fisrt num0ber again (This is right) but then it will not accept a valid number it just keeps jumping back to the beginning asking for the first number... can anyone help?
Here are the two functions that i am using: -
Code:void calc() { clrscr(); cout << "Please enter your first number:"; cin >> num1; validation1(); cout << "Please enter your second number:"; cin >> num2; validation1(); cout << "Please select an operator + - * / %"; cin >> option1; switch (option1) { case '+': add(); break; case '-': subtract(); break; case '*': multiply(); break; case '/': divide(); break; default: cout << "invalid"; } } void validation1() // start of validation1 function { length1 = strlen(num1); convertnum1 = atof(num1); length2 = strlen(num2); convertnum2 = atof(num2); if (length1 <= 6 && convertnum1 > 0 && convertnum1 < 1000) { } if (length2 <= 6 && convertnum2 > 0 && convertnum2 < 999) { } else if (length1 > 6 || length2 > 6) { calc(); // if false returns to calculator funtion } }// end of validation function



LinkBack URL
About LinkBacks


