The following program takes two integers as input and prints number of perfect squares present between those two numbers.

Ex:

Let two numbers be 5 and 16

In this case 2 will be printed as two perfect squares, 9 and 16 are present in between 5 and 16.

Ex:

Let two numbers be 5 and 16

In this case 2 will be printed as two perfect squares, 9 and 16 are present in between 5 and 16.

#include<stdio.h>

#include<math.h>

int main()

{

int x,y,r;

printf("Enter two numbers :");

scanf("%d %d",&x,&y);

x=sqrt(x-1);

y=sqrt(y);

printf("The number of squares present : %d",(y-x));

return 0;

}

### Description:

In the above program let the two elements be A and B. x is the square root of A and y is the square root of B. The squares of x and y lies in between A and B. Therefore square of elements present between x and y are also present in the range of A and b.

### Ex:

5 and 20 are two elements for the program.

x=sqrt(5-1)=2 and y=sqrt(20)=4

According to program the count will be 2.9 and 16 are only two square elements present between 5 and 20.

#### Output:

#### Case 1:

Enter two elements :

3 9

The number of squares present : 2

#### Case 2:

Enter two elements :

15 24

The number of squares present : 1

#### Case 3:

Enter two elements :

25 49

The number of squares present : 3

### Bikash Panda

Blogger / Embedded System Developer at WeArGenius

A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.

#### Latest posts by Bikash Panda (see all)

- Firmata protocol with Raspberry Pi and Arduino - September 13, 2017
- IOT:Power outlet controlled from internet using WeMOS - August 9, 2017
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017

## Leave a Reply