we all know about the function overloading concept used in
C++ and we all learnt abt that.... but that concept is
already came in C in a very smaller propotion ... my
question is IN WHICH CONCEPT THERE IS A USE OF FUNCTION
OVERLOADING IS USED in C language?????????????
Answers were Sorted based on User's Feedback
Answer / sandeep
Function Overloading or Polymorphic Behaviour for C
functions can be seen for those functions who accept
variable number of arguments.
They can take any number of arguments and any type of
arguments, its upon the programmer or the code inside it,
that decides what it wants those arguments to be , int ,
char ,float or something else..
ALthough it is not seperate function that runs for different
number and types of arguments, still for the user, a
function will be provided for different types of list of
input parameters, all being sent to the same ('name of the
')function..
#include <stdarg.h>
enum data_type{ TYPE_INT=0,TYPE_STRING=1};
int max( int num_of_arguments,...)
{
va_list arg_list;
va_start(arg_list, num_of_arguments);
data_type type=va_arg(arg_list,data_type);
if(type=TYPE_INT)
{
int max =0,i;
for(i = 2; i <= num_of_arguments; i++)
{
if((a = va_arg(arg_list, int)) > max)
max = a;
}
}
else
{
//do whaterver..
}
va_end(arg_list);
}
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / vaidyanathan
Hi,MY name is vaidyanathan....and and we have used such type of concepts in the recursion..
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / rohit
Function Overloading or Polymorphic Behaviour for C
functions can be seen for those functions who accept
variable number of arguments.
They can take any number of arguments and any type of
arguments, its upon the programmer or the code inside it,
that decides what it wants those arguments to be , int ,
char ,float or something else..
ALthough it is not seperate function that runs for different
number and types of arguments, still for the user, a
function will be provided for different types of list of
input parameters, all being sent to the same ('name of the
')function..
#include <stdarg.h>
enum data_type{ TYPE_INT=0,TYPE_STRING=1};
int max( int num_of_arguments,...)
{
va_list arg_list;
va_start(arg_list, num_of_arguments);
data_type type=va_arg(arg_list,data_type);
if(type=TYPE_INT)
{
int max =0,i;
for(i = 2; i <= num_of_arguments; i++)
{
if((a = va_arg(arg_list, int)) > max)
max = a;
}
}
else
{
//do whaterver..
}
va_end(arg_list);
}
In c we are not allowed to function overloading with
parameters wherever we like.
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / venkatesh
In c also we are allowed to function overloading with
parameters wherever we like.
Is This Answer Correct ? | 0 Yes | 6 No |
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]
the expression a=30*1000+2768; evalutes to a) 32768 b) -32768 c) 113040 d) 0
1. What will be the output of the following programs. a) #include <stdio.h> Main() { Int x=4; While(x==1) { X=x-1; Printf(ā%dā,x); --x; } }
What is #line in c?
what are far pointers?
C program to read the integer and calculate sum and average using single dimensional array
write a program for odd numbers?
tell me the full form of c?
how many header file is in C language ?
44 Answers College School Exams Tests, CTS, IBM, IMS, Infosys, ME, Sign Solutions, Wipro, XVT,
Write a program to show the workingof auto variable.
main() { printf("hello"); fork(); }