Guys this is a simple question which asks to print all the perfect squares which only has 0,1,4,9 as their digits.I made a program but it is not Working.Pls Help!!
#include <stdio.h> #include <conio.h> int main(){
int i,j,k,a,b;
for(i=0;i<=10;i++)
{
int flag=1; //Set flag=1
int dig;
int x=i*i; //Extracting Digits
while(x!=0 && flag!=0)
{
dig=x%10;
if(dig!=0 || dig!=1|| dig!=4 || dig!=9){flag=0;} //Checking the condition,If it is not
x=x/10; satisfied make flag=0 and exit the
while loop.
}
if(flag==1){printf("%d\n",i*i);}
}
getch(); return 0; }