Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume there are two variables , k and m, each already associated with a positiv

ID: 3669868 • Letter: A

Question

Assume there are two variables , k and m, each already associated with a positive integer value and further assume that k's value is smaller than m's. Write the code necessary to compute the number of perfect squares between k and m. (A perfect square is an integer like 9, 16, 25, 36 that is equal to the square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively).) Associate the number you compute with the variable q. For example, if k and m had the values 10 and 40 respectively, you would assign 3 to q because between 10 and 40 there are these perfect squares: 16, 25, and 36,.

Explanation / Answer

Program:

#include<stdio.h>
#include<math.h>
void main()
{
int k,m;
long n;
printf("Please enter First value:");
scanf("%d",&k);
printf("Please enter Last value:");
scanf("%d",&m);
printf(" Perfect Numbers are:" );
for(n = k*k; n < m; k++)
{
n = n + (2*k + 1);
printf("%ld ", n);
}
}

Output:

Please enter First value: 10

Please enter Last value: 100

Perfect Numbers: 16 25 36 49 64 81 100