Home Article Practice C语言基础1

C语言基础1

2022-11-13 11:13  views:867  source:1480653625@qq.com    

表示包含stdio.h的文件
#include <stdio.h> //std-标准 standard input output
int main() //主函数-程序的入口-main函数有且仅有一个
{
程序从这里开始
在屏幕上输出hello world
使用printf()之前需要:#include
printf("hello world\n");//函数printf - 打印函数(库函数)
return 0;//表示函数的返回值,是整数类型
}
#include <stdio.h>
int main()
{
int age = 20;
short aj = 10;
long bh = 20 ;
long long jk = 300;
printf("%d\n",sizeof(age));//sizeof是看有多少个字节数.格式sizeof().
printf("%d\n",sizeof(aj));
printf("%d\n",sizeof(bh));
printf("%d\n",sizeof(jk));
return 0;
}
浮点型
#include <stdio.h>
int main()
{
float a = 1.1;
double b = 3.3;
printf("%f\n",a);
printf("%lf\n",b);
printf("%d\n",sizeof(a));
printf("%d\n",sizeof(b));
return 0;
}
#include <stdio.h>
int main()
{
char jj = 'acd';//char 是定义字符.
printf("%d\n",jj);//%d是输出整型常量,这里的a对应的是ASIC码,是97.
printf("%c\n",jj); //%c是输出字符常量,
printf("%d\n",sizeof(jj));
return 0;
}
变量,可以变得量
#include <stdio.h>
int main()
{
int age =23;
age = age +1;
printf("%d\n",age);
return 0;
}



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)