C program to pass multiple type of arguments to a function

In this C program, we will learn how we can declare a function that will have different type of variables as arguments?
Submitted by IncludeHelp, on March 22, 2018

Given different type of variables and we have to pass them to a function and process on them in C.

It’s just a simple program, which is demonstrating an example of passing different type of variables/values to a function.

Here is the function that we are using in the program,

void simpleFun(int rollno , char *name , float marks)


  • void is the return type of the function
  • simpleFun is the name of the function
  • int rollno is an integer variable that will keep the copy of actual integer argument (first argument)
  • char *name is the character pointer that will keep the copy of actual string argument (second argument)
  • float marks is the float type of variable that will keep the copy of actual float argument (third argument)

Function calling statement,

simpleFun(Roll , name , marks);

Here, Roll, name and marks are different type of actual arguments.


Program to pass different type of variables/arguments to a function in C

* C program to a pass multiple arguments of different 
* types to a function

#include <stdio.h>

// function to print the argumnets of different types
void simpleFun(int rollno , char *name , float marks)
   printf("\nName is : %s",name);
   printf("\nRoll No. is : %d",rollno);
   // Here ".02f" denotes that we need only two places 
   // after the decimal
   printf("\nMarks are : %f OR Marks are : %.02f",marks,marks);

// main function
int main()
    int Roll = 100;
    float marks = 50.5;
    char name[20] = "Ram srivastav";
    // Passing these values to Function
    simpleFun(Roll , name , marks);
    return 0;


Name is : Ram srivastav
Roll No. is : 100
Marks are : 50.500000 OR Marks are : 50.50

C User-defined Functions Programs »



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.