c语言代码大全和详细解释,c语言必背代码大全加翻译

首页 > 时尚 > 作者:YD1662022-12-28 17:04:20

这些都是基本的 C 程序,可以帮助刚踏入 C 编程世界的新手。快来试试吧:

1、C 语言编程 – Hello World

#include<stdio.h> int main() { printf("Hello world\n"); printf("Linux迷 www.linuxmi.com"); return 0; }

c语言代码大全和详细解释,c语言必背代码大全加翻译(1)

2. C 语言编程 - 执行算术运算

#include<stdio.h> int main() { int a,b; printf("Enter two numbers:"); scanf("%d%d",&a,&b); printf("Sum=%d difference=%d product=%d quotient=%d\n",a b,a-b,a*b,a/b); return 0; }

3.C 编程 - 求圆的面积

#include<stdio.h> #include<math.h> int main() { float r; float N=3.14; float s; //N*r*r;该行必须在输入r值以后 printf("请输入该圆的半径:"); scanf("%f",&r); s=N*r*r; printf("%.7f\n",s);//输出小数点后7位 return 0; }

c语言代码大全和详细解释,c语言必背代码大全加翻译(2)

4.C编程 - 在3个数字中找到最大值

#include<stdio.h> int main() { int a, b, c; printf("\nEnter value of a, b & c : "); scanf("%d %d %d", &a, &b, &c); if ((a > b) && (a > c)) printf("\na is greatest\n"); if ((b > c) && (b > a)) printf("\nb is greatest\n"); if ((c > a) && (c > b)) printf("\nc is greatest\n"); return 0; }

c语言代码大全和详细解释,c语言必背代码大全加翻译(3)

5.C编程 - 查找偶数或奇数

#include<stdio.h> int main() { int n; printf("Enter a number:"); scanf("%d",&n); if(n%2==0) { printf("Number is even\n"); } else { printf("Number is odd\n"); } return 0; }

c语言代码大全和详细解释,c语言必背代码大全加翻译(4)

首页 123下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.