Q:

C program to find square of a number

belongs to collection: C Programming on Numbers

0

In this exercise, we learn how to write a C program to find square of a number?. We will write the C program to find a square of a number. How to display input number square C programming. Logic to find a square of a given number in C programming.

Example,

Input: 2
Output: 4
 
 
Input: 20
Output: 400

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

The below program ask the user to enter the value. After getting the value from the user it will calculate the square of entered number by using arithmetic multiplication operator.

#include<stdio.h>
int main()
{
    float number, square;
    printf("Please Enter any integer Value : ");
    scanf("%f", &number);
    square = number * number;
    printf("square of a given number %.2f is  =  %.2f", number, square);
    return 0;
}

Output1:

Please Enter any integer Value : 20
square of a given number 20.00 is = 400.00

Output2:

Please Enter any integer Value : 4.5
square of a given number 4.50 is = 20.25

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Programming on Numbers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to print the two digit number in words... >>
<< C Program to calculate the square of a number usin...