NUT in Creo |
To count perfect squares in an array
#include <stdio.h>
#include <math.h>
int main()
{
int num[5]={16,29,45,49,4};
int iVar,k, count=0;
float fVar;
for (k = 0; k<5; k=k+1)
{
fVar=sqrt(num[k]);
iVar=fVar;
if(iVar==fVar)
{printf("%d is a perfect square.\n",num[k]);
count++;}
}
printf("count of perfect square=%d \n",count);
return 0;
}
No comments:
Post a Comment