-3
所以我刚开始用发问和反应 学习C语言编程和我决定让我的程序修炼到最终用户说出来应用开关,它关闭?
我首先应用如 - else语句,以便程序根据人的年龄作出反应。 然后,当我到达什么是你最喜欢的颜色部分与开关语句它会刚刚按下任何按钮时关闭。
我的代码:
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <ctype.h>
main()
{
char name[25], c;
int a;
clrscr();
printf("Hello, whats your name? \n");
scanf("%s",name);
printf("nice to meet you %s!!!\n");
printf("Whats your age?");
scanf("%d",&a");
{
if((a <= 21) && (a >= 0))
printf("Young!\n");
else if((a <= 100) && (a >= 22))
printf("old!\n");
else
printf("that's not an age!\n");
}
printf("whats your favorite color? \n"); //this is where the program stops//
scanf("%c",&c);
switch(tolower(c)){
case 'r':printf("Fiery!");break;
case 'o':printf("oranggerrr!!");break;
.
. //basically applied the whole rainbow and put some reactions//
.
getch();
return 0;
}
我不确定我是否理解问题所在。 –
这看起来像他/她在问为什么它的工作。写在评论 – Shial
对不起,我刚刚编辑。^- ^ – Mirisu