新建做业20191011120939

1.编写一个程序,调用一次printf()函数,把你的姓名分别打印在一行。再调用一次printf()函数,把你的姓名分别打印在两行。而后,再调用两次printf()函数,把你的姓名打印在一行。

#include<stdio.h>
int main(void)
{
	printf("朱妍\n");
	printf("朱\n");
	printf("妍\n");
	printf("朱妍\n");
	return 0;
}

2.编写一个程序,打印你的姓名和地址。

#include<stdio.h>
int main(void)
{
	printf("朱妍\n");
	printf("浙江树人大学\n");
	return 0;
}

3.编写一个程序把你的年龄转换整天数,并显示这两个值。这里不用考虑闰年的问题。

#include<stdio.h>
int main(void)
{
	int ageYear;
	int ageDays;
	int totalDays;
	ageYear=18;
	ageDays=365;
	totalDays=ageYear*ageDays;
	printf("totalDays=%d",totalDays);
	return 0;
}

4.编写一个程序,生成如下输出:

For he's a jolly good fellow! For he's a jolly good fellow! For he's a jolly good fellow! Which nobody can deny! 除了main()函数之外,该程序还要调用两个自定义函数:一个名为jolly(),用于打印前三条消息,调用一次打印一条;另外一个函数名为deny(),打印最后一条消息。函数

#include<stdio.h>
void jolly();
void deny();
int main(void)
{
	jolly();
	jolly();
	jolly();
	deny(); 
	return 0;
}
void jolly()
{
	printf("For he's a jolly good fellow!\n");
}

void deny()
{
	printf("Which nobody can deny!\n");
}

5.编写一个程序,生成如下输出:

Brazil,Russia,India,China India,China Brazil,Russia 除了main()之外,该程序还要调用两个自定义函数:一个名为br(),调用一次打印一次“Brazil,Russia”;另外一个名为ic(),调用一次打印一次“India,China"。其余内容在main()函数中完成。code

#include<stdio.h>
void br();
void ic();
int main()
{
	br();
	printf(",");
	ic();
	printf("\n");
	ic();
	printf(",");
	printf("\n");
	br();
	return 0;	
}

void br()
{
	printf("Brazil,Russia");
}

void ic()
{
	printf("Lndia,China");
}

6.编写一个程序,建立一个整型变量toes,并将toes设置为10.程序中还要计算toes的两倍和toes的平方。该程序应打印3个值,并分别描述以示区分。

#include<stdio.h>
int main(void)
{
	int toes=10;
	int dbtoes,pftoes;
	dbtoes=toes*2;
	pftoes=toes*toes;
	printf("%d\n",toes);
	printf("%d\n",dbtoes);
	return 0;	
}

7.许多研究代表,微笑益处多多。编写一个程序,生成如下格式的输出:Smile!Smile!Smile!

Smile!Smile! Smile! 该程序要定义一个函数,该函数被调用一次打印一次“Smile!",根据程序的须要使用该函数。three

#include<stdio.h>
void wx();
void hh();
int main(void)

{
	wx();
	wx();
	wx();
	hh();
	wx();
	wx();
	hh();
	wx();
	hh();
	return 0;
}

void wx()
{
	printf("Smile!");
}

void hh()
{
	printf("\n");
}

8.在C语言中,函数能够调用另外一个函数。编写一个程序,调用一个名为one_three()的函数。该函数在一行打印单词“one”,再调用第二个函数two(),而后在另外一行打印单词“three”。two()函数在一行显示单词“two"。main()函数在调用one-three()函数前要打印短语“staring now”,并在调用完107毕后显示短语“done!”。

void one_three();
void two();
int main(void)
{
	printf("starting now\n");
	one_three();
	printf("done!\n"); 
	return 0;
}

void one_three()
{
	printf("one\n");
	two();
	printf("three\n");
}

void two()
{
	printf("two\n");
}
相关文章
相关标签/搜索