编程学习网为您整理以下代码实例,主要实现:使用字符作为菜单选项,希望可以帮到各位朋友。
#include <stdio.h>
int main()
{
char cResponse = '\0';
printf("\na\tTurn the AC on\n");
printf("b\tTurn the AC off\n");
printf("\nEnter your selection: ");
scanf("%c", &cResponse);
if (cResponse == 'a'){
printf("\nAC is Now on\n");
}
if (cResponse == 'b') {
printf("\nAC is Now off\n");
}
}
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!