Find Square Root of Any Number in C

Google Advertisements

Prev Tutorial Next Tutorial

Find Square Root of Any Number Program in C

For calculate square root of any number we multiply number by 0.5 because square root of any number means power of 1/2 and 1/2=0.5.

Find Square Root of Any Number Program in C

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main() 
{ 
int num,ans; 
clrscr(); 
printf("Enter any number: "); 
scanf("%d",&num); 
ans=pow(num,0.5);
printf("\n Square root of %d is: %d",num,ans); 
getch(); 
} 

Output

Enter any number: 9
Square root of 9 is: 3

Explanation of Program

  • For calculate square root of number we multiply number by 0.5 because square root of any number means power of 1/2 and 1/2=0.5.
  • pow() is a predefined function in math.h header file, it is used for calculate power of any number.

Square Root of number by passing values in function

Find square root of number

#include<stdio.h>
#include<conio.h>
#include<math.h>

int square(int); 
void main()
{
int num;
clrscr();
printf("Enter any number: ");
scanf("%d",&num);
printf("\n Square root of %d is: %d",num,square(num));
getch(); 
}
int square(int num)
{
int ans;
ans=pow(num,0.5);
return(ans); 
getch();
}

Output

Enter any number: 64
Square root of 3 is: 4

Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs