首页 > 其他 > 详细

第8章第1讲简单函数介绍

时间:2017-05-20 19:49:17      阅读:315      评论:0      收藏:0      [点我收藏+]

技术分享

技术分享

技术分享

#include "stdio.h"
#include "math.h"
main()
{
    int x;
    double y;
    scanf("%d",&x);
    y=sqrt(x);
    printf("%lf\n",y);

}

技术分享


#include "stdio.h"

int sum(int x,int y) //自定义函数
{
    return x+y;

}
main()                     //主函数
{

    int s;
    s=sum(2,3);
    printf(“s=%d\n",s);

}

技术分享

#include "stdio.h"
void Hello( )            //自定义函数
{ 
     printf ("Hello world!\n"); 
} 
main()                     //主函数
{
    Hello();
}

技术分享

#include"stdio.h"
void sum(int a,int b)   //自定义函数
{
      int s;
      s=a+b;
      printf("s=%d\n",s);
} 
main()                       //主函数
{
    int x=2,y=3;
    sum(x,y);
}

技术分享

#include"stdio.h"
int sum()                  //自定义函数
{
      int a,b,s;
      scanf("%d%d",&a,&b);
      s=a+b;
      return s;
} 
main()                       //主函数
{

    int s;
    s=sum();
    printf("s=%d\n",s);

}

技术分享

#include"stdio.h"
int sum(int a,int b )    //自定义函数
{
      int s;
      s=a+b;
      return s;
} 
main()                       //主函数
{

    int x,y,s;
    scanf("%d%d",&x,&y);
    s=sum(x,y);
    printf("s=%d\n",s);

}

技术分享

技术分享

技术分享

 

第8章第1讲简单函数介绍

原文:http://www.cnblogs.com/gaiyin/p/6882965.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!