Programming Tutorials

(追記) (追記ここまで)

Find square and square root for a given number in C

By: Jeffrey in C Tutorials on 2012年03月16日 [フレーム]

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;
}



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /