Write C++ program to find cube of a number using function


I have used CodeBlocks 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

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.


  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // Function declaration
  5. double cube(double num);
  6.  
  7.  
  8. int main()
  9. {
  10. int num;
  11. double c;
  12.  
  13. //Inputting number from user
  14. cout<<"Enter any number: "<<endl;
  15. cin>>num;
  16.  
  17. c = cube(num);
  18.  
  19. cout<<"Cube of " <<num << " is "<<c;
  20.  
  21. return 0;
  22. }
  23.  
  24. //Function to find cube of any number
  25. double cube(double num)
  26. {
  27. return (num * num * num);
  28. }
  29.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts