Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Perfect Square - Prove the Computation Time Estimate (http://www.go4expert.com/forums/perfect-square-prove-computation-time-t29062/)

 fmmctg0001 9Sep2012 21:33

Perfect Square - Prove the Computation Time Estimate

my prof was asking me to write a program to find and print the first perfect square (i*i) whose last two digits are both odd.
my answer was this which completely wrong. please any one can help me to fix this program.
And please explain in theory, any program that you write to solve the above problem will
run for infinite time.
Code:

```#include <iostream> using namespace std; int main() {     int num = 0;     int oddnum = 0;         cout<<"Enter a number: ";     cin >> num;         while((num > 0) && (oddnum < 2))     {         int oddnum = num % 100;         num/=100;                 cout<<endl<<"odd number"<<oddnum;         if(oddnum %2 ==0)         {                         cout<<" is even"<<endl;         }         else         {             cout<<" is odd"<<endl;         }             }         return 0; }```

 All times are GMT +5.5. The time now is 05:51.