Q:

C program to pass multiple type of arguments to a function

0

C program to pass multiple type of arguments to a function

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)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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;
}

Output

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C program to pass function as an argument to a fun... >>
<< C program to pass an array of strings to a functio...