Function calls in c

Source: Internet
Author: User

Function calls in c

 
In c/c ++, a function is an essential part of a program. Each program must have a primary function. You can also compile the required functions as needed to implement various functions. Question 1. Use a function to output the largest program in two numbers. # Include <stdio. h> int max (int a, int B) {int z; z = a> B? A: B; return (z) ;}int main () {int a, B, c; scanf ("% d", & a, & B ); c = max (a, B); printf ("% d", c); return 0;} input: 3 8 output: 8. If the type of the function value is different from the type of the expression in the return statement, the function type determines the type of the return value. For numeric data, the value can be automatically converted. For example, in question 1, if the max functions a, B, and z are changed to float, the return Statement should return the value of z as float. Question 2. Use the function to output the maximum value among the three numbers. # Include <stdio. h> int main () {int max (int a, int B, int c); int a = 21, B = 10, c = 1; printf ("Maximum Number: % d ", a); return (0);} int max (int a, int B, int c) {if (B> a) a = B; if (c> a); return a;} result: 21 

Related Article

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.