"Thinkinginc++" 19, about C exercises (1)

Source: Internet
Author: User


/*** function: Establishes a header file, declares a set of functions, has a variable parameter, and the return value includes Void,char,*int,float. Create a. cpp file that contains the above header files, creating a definition of all these functions. Each * definition should simply output the function name, the argument list, and return the type to know that it has been called. * Create another. cpp file that contains the header file and defines an int main () in which to invoke all the * functions that have already been defined. * Time: August 15, 2014 08:18:02*cutter_point*/#ifndef test1_h_included#define test1_h_included#include<iostream> Using namespace std;//declares a set of functions with variable parameters, the return value includes void,char,int,float//function void, declares void fun1 (int),//char function declaration char fun2 ();// The INT function declares int fun3 (float);//float function declares float fun4 (char); #endif//test1_h_included


/*** function: Establishes a header file, declares a set of functions, has a variable parameter, and the return value includes Void,char,*int,float. Create a. cpp file that contains the above header files, creating a definition of all these functions. Each * definition should simply output the function name, the argument list, and return the type to know that it has been called. * Create another. cpp file that contains the header file and defines an int main () in which to invoke all the * functions that have already been defined. * Date: August 15, 2014 08:18:08*cutter_point*//* create a. cpp file that contains the above header files, creating a definition of all of these functions. Each definition should simply output a function name, a parameter list, and return a type to know that it has been called. */#include "test1.h" #include <iostream>using namespace std;void fun1 (int a) {//Simply output function name, parameter list, and return type to know that it has been called cou    t<< "The function fun1 (" <<a<< ") has been called ..."; cout<< "\treturn void\n";}    Char returns the type char fun2 () {///simply outputs the function name, the argument list, and returns the type so that it has been called cout<< "the function fun2 () has been called ...";    cout<< "\treturn char:y\n"; Return ' Y ';} int return type int fun3 (float f) {///Simply output function name, parameter list, and return type to know that it has been called cout<< "the function fun3 (" <<f<< ") has    been called ... ";    cout<< "\treturn int:1\n"; return 1;} Float return type float fun4 (char c) {///Simply output function name, parameter list, and return type to know that it has been called cout<< "the function fun4 (" <<c<< ") H As been called ... ";    cout<< "\treturn float:7.1f\n"; return 7.1f;}



/*** function: Establishes a header file, declares a set of functions, has a variable parameter, and the return value includes Void,char,*int,float. Create a. cpp file that contains the above header files, creating a definition of all these functions. Each * definition should simply output the function name, the argument list, and return the type to know that it has been called. * Create another. cpp file that contains the header file and defines an int main () in which to invoke all the * functions that have already been defined. * Time: August 15, 2014 08:18:13*cutter_point*///#include "test1.h" #include "test1.cpp" #include <iostream> #include <cstdlib>using namespace Std;int Main () {    fun1 (998);    Fun2 ();    FUN3 (3.8f);    Fun4 (' L ');    System ("pause");    return 0;}





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.