1:使用printf函数对不同类型变量进行输出,%符号,代表输出类型, 代表换行,代码如下:
// 2.2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" int main() { int iInt=10; /*定义整型变量*/ char cChar='A'; /*定义字符型变量*/ float fFloat=12.34f; /*定义单精度浮点型*/ printf("the int is: %d ",iInt); /*使用printf函数输出整型*/ printf("the char is: %c ",cChar); /*输出字符型*/ printf("the float is: %f ",fFloat); /*输出浮点型*/ printf("the stirng is: %s ","I LOVE YOU"); /*输出字符串*/ return 0; }
运行结果如下: