# Checking Whether A Number is a Perfect Square or Not using C Program with Source Code

## Introduction

The C programming language is a procedural programming language. Between 1969 and 1973, Dennis Ritchie worked on the project. It was created primarily as a system programming language for developing operating systems. Low-level memory access, a small collection of keywords, and a clean style are all qualities that make C language excellent for system programming, such as operating system or compiler development.

## Why Learn C Programming Language?

Because it mixes the characteristics of high-level languages with the functionalism of assembly language, C is often referred to as a middle-level computer language. The manipulation of bits, bytes, and addresses in C gives the programmer more control over how the program will behave and more direct access to the underlying hardware mechanisms.

Working programmers influenced, influenced, and field-tested C. As a result, C provides the programmer with exactly what he or she want. C++ is a more advanced version of the C programming language. C++ incorporates all of the features of C, as well as support for object-oriented programming (OOP). Furthermore, C++ includes numerous enhancements and features that make it a “better C,” regardless of whether or not it is used for object-oriented programming.

## Checking weather if a number is perfect square or not

The best way to learn is to do. Hence, what better way to learn C programming language (if you know the basics) than to code your first mini project. In this tutorial we are going to build a program for checking weather if a number is perfect square or not using c programming language. Keep in mind this is a mini project for absolute beginners and intermediate programmers as well.

A perfect square is defined as a whole number that is the square of another whole number. For example, 16 is the square of 4, hence 16 is a perfect square and if the given number is 5 then 5 is returned as not being a perfect square.

Our Approach for checking weather if a number is perfect square or not is:

• Enter any x value.
• Save the square root in fVar, a float variable.
• Insert fVar into iVar (an integer variable) with the formula iVar=fVar.
• Now compare the values of iVar and fVar. iVar and fVar will not be the same if the number is not a perfect square.

// C program to check number is perfect square or not
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>

int main()
{
int num;
int iVar;
float fVar;
printf("Enter an integer number: ");
scanf("%d",&num);
fVar=sqrt((double)num);
iVar=fVar;
if(iVar==fVar)
printf("%d is a perfect square.",num);
else
printf("%d is not a perfect square.",num);
return 0;
}

## Output

• Output Screen Shot 1 :
• Output Screen Shot 2 :
• Output Screen Shot 3 :

## You may Also Like

SHARE Checking Whether A Number is a Perfect Square or Not using C Program with Source Code