# Find square and square root for a given number in C

By: Jeffrey Emailed: 1757 times Printed: 2444 times

Latest comments
 By: rohit kumar - how this program is work By: Kirti - Hi..thx for the hadoop in By: Spijker - I have altered the code a By: ali mohammed - why we use the java in ne By: ali mohammed - why we use the java in ne By: mizhelle - when I exported the data By: raul - no output as well, i'm ge By: Rajesh - thanx very much... By: Suindu De - Suppose we are executing

This simple C program shows how to find square and square root for a given number.

```#include <math.h>   /* for sqrt() function */ #include <stdio.h> int main( ) {     /* variable named x with floating-point data type */     float x;     /* standard output  writing a positive floating number */     printf("\nEnter one positive number (1, 2, 3. . .): ");     /* standard input reading floating number */     scanf("%f", &x);     printf("\nx = %f ", x);     printf("\nSquare for x is = %f", x * x);     // sqrt() is the predefined function, defined in math.h     printf("\nSquare root for x is = %f\n", sqrt(x));     return 0; } ```

 Sponsored Links If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

# Comments(0)

Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Jeffrey
 Command-line arguments in C Simple arithmetic calculations in C Find square and square root for a given number in C Calculating total based on the given quantity and price in C++ The Object (compound) Type in PHP

More Tutorials in C
 Sum of the elements of an array in C Printing a simple histogram in C Sorting an integer array in C Find square and square root for a given number in C Simple arithmetic calculations in C Command-line arguments in C Calculator in C Passing double value to a function in C Passing pointer to a function in C Infix to Prefix And Postfix in C while, do while and for loops in C Unicode and UTF-8 in C Formatting with printf in C if, if...else and switch statements in C with samples Statements in C

More Latest News
Most Viewed Articles (in C )
 Using memset(), memcpy(), and memmove() in C Open, Creat, Close, Unlink system calls sample program in C UNIX read and write system calls sample program in C Find square and square root for a given number in C lseek() sample program in C assert() Function Example program in C Character Arrays in C Using free() Function in C Printing a simple histogram in C perror() Function - example program in C Infix to Prefix And Postfix in C scanf and sscanf sample program in C Macro Substitution using #define in C goto and labels in C Fopen and Getc implementation program in C
Most Emailed Articles (in C)
 Type Conversions in C (String to Integer, isdigit() etc) Pointers and Arrays in C Using malloc() Function in C Using realloc() Function in C The Birth and history of C Programming Language Basics of C Getting Started with C Variables and Arithmetic Expressions in C The for statement in C Symbolic Constants using #define in C File Copying in C Character Counting sample program in C Line Counting sample program in C Word Counting sample program in C Arrays sample program in C