Write a program to find the power of a number using constructor with default argument
Answers
Answered by
0
#include
<iostream.h>
#
include<conio.h>//
Class definition of Cubeclass C1
{
int a, b, c;
public:C1(int a1=0, int b1=0, int e1=0) //
Default parameter constructor
r{
a=a1;b=b1;c=e1;
}int Vlm() // Calculation of Volume{
return a*b*c;}};int main(){clrscr();C1
x(1,2,5),y;cout<<x.Vlm()
<<"\n";cout<<y.Vlm();getch();return
0
;}
<iostream.h>
#
include<conio.h>//
Class definition of Cubeclass C1
{
int a, b, c;
public:C1(int a1=0, int b1=0, int e1=0) //
Default parameter constructor
r{
a=a1;b=b1;c=e1;
}int Vlm() // Calculation of Volume{
return a*b*c;}};int main(){clrscr();C1
x(1,2,5),y;cout<<x.Vlm()
<<"\n";cout<<y.Vlm();getch();return
0
;}
Answered by
2
Hey there Programmer
#include <iostream> using namespace std;
void display(char = '*', int = 1);
int main() { cout << "No argument passed:\n";
display(); cout << "\nFirst argument passed:\n";
display('#'); cout << "\nBoth argument passed:\n"; display('$', 5);
return 0; } void display(char c, int n) { for(int i = 1; i <= n; ++i) { cout << c; } cout << endl;
}
Hope you like it
#include <iostream> using namespace std;
void display(char = '*', int = 1);
int main() { cout << "No argument passed:\n";
display(); cout << "\nFirst argument passed:\n";
display('#'); cout << "\nBoth argument passed:\n"; display('$', 5);
return 0; } void display(char c, int n) { for(int i = 1; i <= n; ++i) { cout << c; } cout << endl;
}
Hope you like it
Similar questions