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.
#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;
        cout<<endl<<"odd number"<<oddnum;
        if(oddnum %2 ==0)
            cout<<" is even"<<endl;
            cout<<" is odd"<<endl;
    return 0;

Last edited by shabbir; 10Sep2012 at 01:07.. Reason: Code blocks