文章目录
##例题7.1
#include<stdio.h>
int main()
{
void print_star();
void print_message();
print_star();
print_message();
print_star();
return 0;
}
void print_star()
{
printf("******************\n");
}
void print_message()
{
printf("How do you do!\n");
}
运行结果如下:
##例题7.2
int max(int x,int y)
{
int z;
z=x>y? x:y;
return 0;
}
#include<stdio.h>
int main()
{
int max(int x,int y);
int a,b,c;
printf("please enter two integer numbers:");
scanf("%d,%d",&a,&b);
c=max(a,b);
printf("max is %d\n",c);
return 0;
}
运行结果如下:
##例题7.3
#include<stdio.h>
int main()
{
int max(float x,float y);
float a,b;
int c;
scanf("%f,%f",&a,&b);
c=max(a,b);
printf("max is %d\n",c);
return 0;
}
int max(float x,float y)
{
float z;
z=x>y? x:y;
return(z);
}
运行结果如下:
##例题7.4
#include<stdio.h>
int main()
{
float add(float x,float y);
float a,b,c;
printf("Please enter a and b:");
scanf("%f,%f",&a,&b);
c=add(a,b);
printf("sum is %f\n",c);
return 0;
}
float add(float x,float y)
{
float z;
z=x+y;
return (z);
}
运行结果如下: