Functions in C

Write a program to Use of simple functions in C. Functions is a bunch of statements grouped together. A function is provided with zero or more arguments, and it executes the statements on it.

Example:
Input:  a=3, b=4, c=6, d=5
Output: 6

C Program

#include <stdio.h>

int max_of_four(int aint bint cint d)
{
    if (a > b && a > c && a > d)
        return a;
    else if (b > a && b > c && b > d)
        return b;
    else if (c > a && c > b && c > d)
        return c;
    else
        return d;
}

int main()
{

    int a = 3b = 4c = 6d = 5;
    int ans = max_of_four(abcd);
    printf("%d"ans);

    return 0;
}


No comments:

Post a Comment