C - Passing multiple values to a function

Introduction

You can pass many arguments into a function.

As long as you properly declare the arguments as specific types and separate them all with commas.

The following code shows how to declare two variables.

Demo

#include <stdio.h>

void display(int count,char ch);

int main()//from w w w . j  a  va2s  .  c o  m
{
    int value;

    value = 2;

    while(value<=64)
    {
        display(value,'=');
        printf("Value is %d\n",value);
        value = value * 2;
    }
    return(0);
}

void display(int count,char ch)
{
    int x;

    for(x=0;x<count;x=x+1)
        putchar(ch);
    putchar('\n');
}

Result

Related Topic