2.12
6.
编写一个程序,创建一个整型变量toes,并将toes设置为10。 程序中还要计算toes的两倍和toes的平方。该程序应打印3个值,并分别描述以示区分
#include<stdio.h>
#define tose 10
int main()
{
printf("%d %d %d", tose, tose * 2, tose * tose);
}
8.
在
C
语言中,函数可以调用另一个函数。编写一个程序,调用一
个名为
one_three()
的函数。该函数在一行打印单词
“one”
,再调用第
2
个函数
two()
,然后在另一行打印单词
“three”
。
two()
函数在一行显
示单词
“two”
。
main()
函数在调用
one_three()
函数前要打印短
语
“starting now:”
,并在调用完毕后显示短语
“done!”
。因此,该程
序的输出应如下所示:
starting now:
one
two
three
done!
#include<stdio.h>
void one_three()
{
printf("one\n");
}
void two()
{
printf("two\n");
printf("three\n");
}
int main()
{
printf("starting now:\n");
one_three();
two();
printf("done");
}