my code stock.com

Mubasshir Ahmed

11461 - Square Numbers
by Mubasshir Ahmed

A square number is an integer number whose square root is also an integer. For example 1, 4, 81 are
some square numbers. Given two numbers a and b you will have to find out how many square numbers
are there between a and b (inclusive).
Input
The input file contains at most 201 lines of inputs. Each line contains two integers a and b (0 < a ≤
b ≤ 100000). Input is terminated by a line containing two zeroes. This line should not be processed.
Output
For each line of input produce one line of output. This line contains an integer which denotes how
many square numbers are there between a and b (inclusive).
Sample Input
1 4
1 10
0 0
Sample Output
2 3

Snippet options

Download: Download snippet as 11461-square-numbers.cpp.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std ;
int main()
{
    int a , b ;
   while( scanf("%d%d",&a,&b)){
    int i=0 ,c ,count =0 ;
    if(a==0 && b==0)break;

for(i=a;i<=b;i++)
    {
        c=sqrt(i);
        if(c*c==i)
        {
            count++;

        }
    }
    printf("%d\n",count);
   }

    return  0;
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.