简体   繁体   English

要求用户重复该程序

[英]ask user to repeat the program

i am trying to make the program repeat if the user choose Y, but if the user choose N, the program will display the total fee of the course.如果用户选择 Y,我试图让程序重复,但如果用户选择 N,程序将显示课程的总费用。 i am using do...while loop here and i cant figure out why, when the user key in Y, the program didnt repeat and how to display the total fee.我在这里使用 do...while 循环,我不知道为什么,当用户键入 Y 时,程序没有重复以及如何显示总费用。 here is my coding, it's not done yet这是我的编码,还没有完成

#include<stdio.h>
#define A 100
#define B 100
#define C 120
#define D 120
#define E 130

int main()
{
    int totalFee;
    char code, join;
    
    printf("\t\t Training Centre\n");

    do
    {
        printf("\nEnter course code: ");
        scanf(" %c", &code);
        
            if(code == 'A')
            {
                printf("Course name: C for beginner\nFees: 100");
            }
        
            else if(code == 'B')
            {
                printf("Course name: C++ for beginner\nFees: 110");
            }
            
            else if(code == 'C')
            {
                printf("Course name: Java for beginner\nFees: 120");
            }
        
            else if(code == 'D')
            {
                printf("Course name: Phyton for beginner\nD\nFees: 130");
            }
        
            else
            {
                printf("Course name: PHP for beginner\nFees: 140");
            }
    
        printf("\n\nDo you want to join other class? (Enter Y for 'Yes' / N for 'N'): ");
        scanf(" %c", join);
    }
    
    while (join == 'Y' || join == 'y');
    
}

You forgot the address operator & in scanf(" %c", join) ;您忘记了scanf(" %c", join)中的地址运算符& a sensible compiler with appropriate options would have warned about that. a sensible compiler with appropriate options would have warned about that.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 要求用户重复程序或退出 C - Ask user to repeat the program or exit in C 根据用户重复c程序 - Repeat the c program according to user C程序:要求用户定义数组的长度 - C Program: Ask a user to define an array's length 切换输入错误字符后如何重复菜单(再次询问用户输入) - How to repeat a menu (ask for user input again) after switch got a wrong input character 尝试编写一个要求用户输入括号和方括号的程序。 然后程序将告诉用户他们是否正确嵌套 - Trying to write a program that ask the user to input parentheses and brackets. The program will then tell the users whether they are properly nested 询问用户输入和命令以继续或停止。 用户希望程序停止后,它会向用户提供程序期间输入的最大值和最小值? - Ask user input and a command to continue or stop. After user wants program to stop, it give user the max and min value entered during the program? C:程序不会再询问用户是否使用fflush(stdin)输入了字符 - C: Program won't ask the user again if the user inputs a character using fflush(stdin) 在C编程中,执行Do-While循环以询问用户是否希望程序再次运行 - In C programming make a Do-While loop to ask user if they want the program to run again 计算元音、辅音和单词总数的程序,并再次要求用户检查字符串中的字母 - Program to count the total number of vowels, consonants and words and ask for a user again for check for a letter for a string 如果用户未输入正确的值,则使C程序重新开始并再次请求输入 - Making a C program return to the start and ask for input again if a user did not input the right value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM