Monday 16 June 2014

C++ program to print the four digit numbers whose sum of squares of first half and second half are equal



Here is a C++ program to print the four digit numbers whose sum of squares of first half and second half are equal


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int y,fsh,sdh;
    for(int i=1000;i<10000;i++)
    {
        fsh=i%100;
        sdh=i/100;
        if(fsh*fsh==sdh*sdh)
           cout<<i<<" ";
    }
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment