function or methode overloading in c programming -99webcode

Methode or function overloading in c programming-99webcode

Methode or function overloading in c programming


//c does not supoorted methode or fuction overloading

//if we take add instead of add1 and add2 it gives "conflicting type for add" error

#include<stdio.h>

int add(int a,int b)

{

return a+b;

}

float add1(float a,float b)

{

return a+b;

}

double add2(float a,float b)

{

return a+b;

}

int main()

{

int my1=add(5,4);

printf("%d\n",my1);

float my2=add1(4.2,4.7);

printf("%f\n",my2);

float my3=add2(5.7,11.5);

printf("%f\n",my3);

//return 0;

}  

Post a Comment (0)
Previous Post Next Post