15/11/2015

C++ Program To Find Cube Using Functions

Problem :- Write A C++ Program To Find Cube Of Any Number Using Functions .

Logic :- Very Simple Just pass the value in Function If you don't know Function You Can see the another Example C Program to Display Prime Numbers Between Intervals Using Using Function

Solution :-

#include<iostream>
using namespace std;

int main()
{
//By-Ghanendra Yadav
                                           
float cube(float);  //Function Type is float
float num,cu;
cout<<"Enter Any Number To Find Cube :\t";
cin>>num;
cu=cube(num);                                    
cout<<"\nCube Of "<<num<<" is = "<<cu<<endl<<endl;
return 0;
}

float cube(float a)
{
float cu;
cu=a*a*a;
return(cu);
}

Output:-

C++ Program To Find Cube Using Functions

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

4 comments:

  1. Replies
    1. Hello,

      as you can see that I have taken Two float variable num and cu. in num we store user input and in cu we are taking the final output and printing in console.

      Don't worry this program is very old when I was beginner in programming this is just a n experiment.

      Keep visit, Like and Share.

      Delete
    2. bro do u whatsapp??? my num is 03431530052 i am doing BS it i may have some problems ... and need help

      Delete
    3. Hello, Faheem

      I have whatsapp but sorry to inform you I don't use whatsapp for programming related issue.

      I have some platform where you can join or follow me. I can help you better you can ask me anything related to programming I definitely try to solve your problem.

      Check These Link and join me.

      Learn About Blogging- Click Here

      1. Facebook Page- Click Here

      2. Facebook Group- Click Here

      3. Twitter- Click Here

      4. Google Plus- Click Here

      5. Pinterst- Click Here

      6. Linkedin Group- Click Here

      7. Tumblr- Click Here

      8. Github- Click Here

      9. Quora Blog- Click Here


      Thanks and keep support by sharing.

      Delete