C++ Program using Function Overloading to Implement Drawchar

Write a program to show the concept of Function Overloading satisfying the main function ( ) shown below. There should be two drawchar functions. int main( ) { clrscr( ); drawchar( ); drawchar('+'); getch(); return 0; }

Write a program to show the concept of Function Overloading satisfying the main function ( ) shown below. There should be two drawchar functions.
                        int main( )
{
clrscr( );
drawchar( );
drawchar('+');
getch();
return 0;
}


Source Code:
#include<iostream.h>
#include<conio.h>
void drawchar(char x='*');
int main(){
  clrscr();
  drawchar( );
  cout<<"\n";
  drawchar('+');

  getch();
  return 0;
}
void drawchar(char x){

  for(int i=1;i<=4;i++){
    for(int j=4;j>i;j--){
      cout<<" ";
      }
    for(int k=1;k<2*i;k++){
      cout<<x;
    }
   cout<<"\n";
  }

 for(int m=1;m<=3;m++){
    for(int n=1;n<=m;n++){
      cout<<" ";
    }
   for(int l=6;l>=2*m;l--){
      cout<<x;
   }
   cout<<"\n";
  }
}




Output:
 

You May Also Like...

Socialize with Us