Thursday, 11 September 2014

Check that given number is Perfect Square Or Not

/*Check that given number is Perfect Square Or Not*/

Solution:

#include<stdio.h>
#include<conio.h>
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main (){
 float i,j = 0,num;
 printf("Enter a number:");
 scanf("%f",&num);

 for (i = 2; i <= num/2; i++){
 
  j = num/i;
  if (j == i){
  
   printf("\nPerfect Square.\n\a");
   break;
  }
  else{
  
   printf("\nNot perfect Square.\n");
   break;
  }
 }
 getch();
 return 0;
}

No comments:

Post a Comment