Write a program in C to check whether a given number is a perfect cube or not a perfect cube

  • برمجة سي c

Write a program in C to check whether a given number is a perfect cube or not


Expected Output :
Input a number: 125
The number is a perfect Cube of 5

الأجوبة

# include <stdio.h>
# include <stdlib.h>
# include <math.h>


int main() 
{ 
int num, curoot,ans; 

 printf("\n\n Check whether a number is a perfect cube or not: \n");
 printf(" -----------------------------------------------------\n");
    printf(" Input a number: ");
    scanf("%d",&num);
curoot=round(pow(num, 1.0/3.0));

if(curoot*curoot*curoot==num)
{
  printf(" The number is a perfect Cube of %d \n",curoot);   
}
else
{
  printf(" The number is not a perfect Cube.\n");   
}
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...