*学习C语言第一天:
2019-10-05
例1.在屏幕上输入以下字符:
I’s not difficult to learn C progarm!
***************************
are you ready?
#include <stdio.h>
void main()
{
printf(“It’s not difficult to learn C program!”);
printf("******************");
printf(“Are you ready?\n”);
}
例1.2 由键盘输入两个整数,求着两个数的平方和并输出。
程序代码
#include<stdio.h>
void main()
{
int x,y,s_sum;
printf(“请输入x,y的值:\n”);
scanf("%d,%d,",&x,&y);
s_sum=xx+yy;
printf(“平方和是:%d\n”,s_sum);
}
例1.3 由键盘输入两个整数,求这两个整数的平均值并输出
#include <stdio.h>
void main()
{
int x,y;
float ave;
printf(“please input the value of x,y:\n”);
scanf("%d,%d/n",&x,&y);
ave=average(x,y);
printf("(%d+%d)/2.0=%f/n",x,y,ave);
}
flat average(int a,int b)
{
float c:
c=(a+b)/2.0;
return c;
}
编辑-》编译-》连接 ->生产可执行的程序软件