2024年4月14日发(作者:)
1.单行注释:由双斜杠//表示,下面我们来看看一个单行注
释的例子。
示例:
#include
#include
void main(){
// 这是一个注释行,下面语句打印一个字符串:"Hello C"
printf("Hello C"); // printing information
// 这是另一个注释行,下面语句求两个变量的值
int a = 10, b = 20;
int c = 0;
c = a + b;
printf("The sum of a+b is :%d", c);
}
执行上面示例代码,得到以下结果 -
Hello C
The sum of a+b is :30
2多行注释: 多行注释由斜杠星号/* ... */表示。它可以占用
许多行代码,但不能嵌套。语法如下:
/*
code
to be commented
line 3
*/
示例:
#include
#include
void main() {
/*printing
information*/
printf("Hello Cn");
*/
int a = 10, b = 20;
int c = a * b;
printf("The value of (a * b) is :%d n", c);
}
执行上面示例代码,得到以下结果 -
Hello C
The value of (a * b) is :200
发布者:admin,转转请注明出处:http://www.yc00.com/web/1713074268a2177740.html
评论列表(0条)