C++ Functions Without Arguments and with Return Value

//Type of Functions

//Function without arguments and with return value. 

#include<iostream>

using namespace std;

float VOCY();

float VOCO();

float VOSP();

float SI();

float POWER();

float Maximum();

float minimum();

float oddsum();

float VOCY()

{

float r,h,a;

cout<<"Enter the radius of cylinder: ";

cin>>r;

cout<<"Enter the Height of cylinder: ";

cin>>h;

return 3.14*r*r*h;

}

float VOCO()

{

float r,h,a;

cout<<"Enter the radius of cone: ";

cin>>r;

cout<<"Enter the Height of cone: ";

cin>>h;

return 0.3*3.14*r*r*h;

}

float VOSP()

{

float r,h,a;

cout<<"Enter the radius of Sphere: ";

cin>>r;

return 1.3*3.14*r*r*r;

}

float SI()

{

float P,R,T;

cout<<"Enter the Principal amount: ";

cin>>P;

cout<<"Enter the Rate of the interest: ";

cin>>R;

cout<<"Enter the Time period: ";

cin>>T;


cout<<"Interest is :";

return P*R*T/100;

}

float POWER()

{

float i,x,y,g=1;

cout<<"Enter the Base: ";

cin>>x;

cout<<"Enter the Exponent: ";

cin>>y;

for(i=1;i<=y;i++)

{

g=g*x;

}

return g;

}

float Maximum()

{

float i,x,y;

cout<<"Enter the first number: ";

cin>>x;

cout<<"Enter the second number: ";

cin>>y;

if(x>y)

{

cout<<"greater number is ";

return x;

}

else

{

cout<<"greater number";

return y;

}

}

float Minimum()

{

float i,x,y;

cout<<"Enter the first number: ";

cin>>x;

cout<<"Enter the second number: ";

cin>>y;

if(x>y)

{

cout<<"Smaller number is ";

return y;

}

else

{

cout<<"Smaller number is ";

return x;

}

}

float oddsum()

{

int  i,oddsum=0,n;

cout<<"Enter number: ";

cin>>n;

for(i=1;i<=n;i++)

{

if(i%2==1)

oddsum+=i;

}

cout<<"Oddsum is: ";

return oddsum;

}

int main()

{

cout<<VOCY();

cout<<"\n===================================\n";

cout<<VOCO();

cout<<"\n===================================\n";

cout<<VOSP();

cout<<"\n===================================\n";

cout<<SI();

cout<<"\n===================================\n";

cout<<POWER();

cout<<"\n===================================\n";

cout<<Maximum();

cout<<"\n===================================\n";

cout<<Minimum();

cout<<"\n===================================\n";

cout<<oddsum();

cout<<"\n===================================\n";

}

Comments

Popular posts from this blog