Enter 10 numbers to find out the number of the largest element (array as function parameter)

Source: Internet
Author: User

Summary:

When you call a function that has parameters, you need to provide an actual participation. An actual participation can be a constant, variable, or expression.

An array element acts as a variable.

An array element can be used as a function, and its method is the same as a variable. Passes the value of the array element to the shape. The array name can also be used as an actual and formal participation, passing the first address of the array.

An array element can be used as a function, but not as a form.

Because the shape participates in the function call temporarily allocates the storage unit. It is not possible to allocate a storage unit independently for an array element (an array is a population, which occupies a contiguous storage unit in memory). When an array element is used as a function, the actual participation is passed to the formal participation. Is the "value pass", the data passing direction is to participate in the formal participation. One-way delivery.

#include <stdio.h>int max (int x,int y) {return (x>y?

X:Y);} int main () {int a[10];int i,m,n;for (i=0;i<10;i++) scanf ("%d", &a[i]), for (i=0,m=a[0];i<10;i++) {if (max (m,a[i ]) >m) {m=a[i];n=i;}} printf ("The largest number is%d\nit is The%dth number\n", m,n+1); return 0;}



Enter 10 numbers to find out the number of the largest element (array as function parameter)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.