Basic

Switch Case

Goto

Operators

if Statement

Nested if

While Loop

For Loop

Array

Patterns

Excersises


C Program to Check Whether a Given Number is Perfect Root or Not


The following example shows, how to check Whether a given number is perfect root or not in C program

Example : pgm.c

#include<stdio.h>
#include<math.h>
int main(){
  int n,r,p;
  printf("\nEnter Number : ");
  scanf("%d",&n);
  r=sqrt(n);
  if(r*r==n){
    printf("\nPerfect Root");
  }else{
    printf("\nNot a Perfect Root");
  }
  return 0;
}

Output 1:

Enter Number : 25
Perfect Root

Output 2:

Enter Number : 26
Not a Perfect Root