本文介绍了如何使程序检查预定义的答案与输入的答案并打印最终结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过使用

I tried using

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

int main()
{
    char a,b;
    int x=1,correct=0,incorrect=0,unattempted=0;
    printf("Enter Answer for Q.%d: ",x);
    scanf("%c",&a);
    x++;

    switch(a)
    {
    case 'A':
        printf("Correct \n");
        correct++;
        break;
    case 'U':
        unattempted++;
        break;
    default:
        printf("Wrong \n");
        incorrect++;
        break;
    }
    printf("Enter Answer for Q.2:");
    scanf("%c",&b);
    x++;
    switch(b)
    {
    case 'A':
        printf("Correct \n");
        correct++;
        break;
    default:
        printf("Wrong \n");
        incorrect++;
        break;
    }
    printf("Correct = %d ; Incorrect = %d ; Unattempted = %d",correct,incorrect,unattempted);
    return 0;
}



但输出为


But get the output as

Enter Answer for Q.1: A
Correct
Enter Answer for Q.2:Wrong
Correct = 1 ; Incorrect = 1 ; Unattempted = 0
Process returned 0 (0x0)   execution time : 2.281 s
Press any key to continue.







有人可以帮我提供代码。




Can somebody please help me with the code.

推荐答案


这篇关于如何使程序检查预定义的答案与输入的答案并打印最终结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 22:02
查看更多