Write C program to find cube of a number using function


Introduction

I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Write C program to find cube of a number using function


  1. #include <stdio.h>
  2.  
  3. // Function declaration
  4. double cube(double num);
  5.  
  6. int main()
  7. {
  8. int num;
  9. double c;
  10.  
  11. //Inputting number from user
  12. printf("Enter any number: ");
  13. scanf("%d", &num);
  14.  
  15. c = cube(num);
  16.  
  17. printf("Cube of %d is %.2f", num, c);
  18.  
  19. return 0;
  20. }
  21.  
  22. //Function to find cube of any number
  23. double cube(double num)
  24. {
  25. return (num * num * num);
  26. }
  27.  

Result

C language

     





Related Topics




Popular Posts