记录C Primer Plus 的学习

这是今天的代码。。。就当练打字的了。。。

这个

//fathm_ft.c 把2英寸转化成英尺,1英寸(fathoms)=6英尺(feet)
#include <stdio.h>
int main(void)
{
	int fathoms=2;
	int feet;

	feet=6*fathoms;
	printf("There is %d feet in %d fathoms!\n",feet,fathoms);
	printf("Yes,I said %d feet!\n",6*fathoms);

	return 0;
}

还有这个

//two_func.c--一个文件中包含两个函数
#include <stdio.h>
void butler(void);//函数声明function declaration
int main()
{
	printf("I will summon the butler function.\n");
	butler();//函数调用function call
	printf("Yes.Bring me some tea and writeable DVDs.\n");

	return 0;
}
void butler(void)//函数定义function definition
{
	printf("You rang,sir?");
}

还有这个

/*
  第一次打印内容:Gustav Mahler
  第二次打印内容:Gustav
  仍然是第二次打印内容:Mahler
  第三次核第四次打印内容:Gustav Mahler
*/
#include <stdio.h>
int main(void)
{
	printf("Gustav Mahler\n");
	printf("Gustav ");
	printf("Mahler\n");
}

还有这个

//编写一个程序 把你的年龄转换成天数 不计闰年
#include <stdio.h>
int main(void)
{
	int age=20;
	int year=365;
	
	printf("天数为:%d天\n",age*year);
	
	return 0;
}

还有这个

//编写一个程序
#include <stdio.h>
void jolly(void);//调用jolly函数
void deny(void);//调用deny函数
int main(void)
{
	jolly();
	deny();
}
void jolly(void)
{
	printf("For he's a jolly good follow!\n");
	printf("For he's a jolly good follow!\n");
	printf("For he's a jolly good follow!\n");
}
void deny(void)
{
	printf("Witch nobody can denyn!\n");
}

还有这个

//编写一个程序
#include <stdio.h>
void br(void);//调用br函数
void ic(void);//调用ic函数
int main(void)
{
	br();
	ic();
	
	printf("India,China\n");
	printf("Brazil,Russia,\n");
}
void br(void)
{
	printf("Brazil,Russia,");
}
void ic(void)
{
	printf("India,China\n");
}

还有这个

//编写一个程序,创建整型toes,并且打印toes的两倍和平方
#include <stdio.h>
int main(void)
{
	int toes=10;
	int toes1;
	int toes2;
	toes1=2*toes;
	toes2=toes*toes;
	printf("toes的原值为%d\n",toes);
	printf("toes的2倍为%d\n",toes1);
	printf("toes的平方为%d\n",toes2);

	return 0;
}

还有这个

//编写一个程序,创建整型toes,并且打印toes的两倍和平方
#include <stdio.h>
int main(void)
{
	int toes=10;
	int toes1;
	int toes2;
	toes1=2*toes;
	toes2=toes*toes;
	printf("toes的原值为%d\n",toes);
	printf("toes的2倍为%d\n",toes1);
	printf("toes的平方为%d\n",toes2);

	return 0;
}

还有这个

/*
编写一个程序,程序中要调用名为one_three()的函数。
该函数要在一行中显示单词"one",再调用two()函数,
然后再在另一行中显示单词"three"。
函数two()应该能在一行中显示单词"two"。
main()函数应该在调用one_three()函数之前显示短语"starting now:",
函数调用之后要显示"done!"o这样,最后的输出结果应如下所示:
starting now
one
two
three
done !
*/
#include <stdio.h>
void one_three(void);
void two(void);
int main(void)
{
	printf("starting now\n");
	one_three();
	printf("done!");
}
void one_three(void)
{
	printf("one\n");
	two();
	printf("three\n");
}
void two(void)
{
	printf("two\n");

}

还有。。。没了。但是明天还有!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值