Write code for finding square root of a given no ......
Software QA/Tests Interview Questions from Microsoft
(Continued from previous question...)
Write code for finding square root of a given no ......
Q:
Microsoft Interview Question for Software Engineer in Tests about Coding
Write code for finding square root of a given no.
A:
#include<stdio.h>
void main(){
long int n,i,sum=0,k=1,f=0;
printf("ENTER THE NUMBER");
scanf("%ld",&n);
while(1){
sum+=(2*k-1);
if(sum==n)
{
f=1;
break;
}
else if(sum>n)
break;
k++;
}
if(f==1)
printf("This Number is Square Number Square root is:%d",k);
else
printf("This Number is not a Square Number");
}
(Continued on next question...)
Other Interview Questions
|