C++语言程序设计

| 程序2-4：

#include <stdio.h>
#define MAX_WORD 20
void main()
{
int x;
float a;
char ch, empty;
char word[MAX_WORD];
printf("Enter an integer: ");
scanf("%d", &x);
printf("Enter a float: ");
scanf("%f", &a);
fflush(stdin); // 清空输入缓冲区
printf("Enter a character: ");
scanf("%c", &ch);
printf("Enter a string: ");
scanf("%s", word);
printf("Your integer was: %d\n", x);
printf("Your float was: %f\n", a);
printf("Your character was: %c\n", ch);
printf("Your word was: %s\n", word);
}