I created a history review program in C language.
In case 10, there are problems with the 2 if statements enclosed.
1. Question 1: The U.S. Constitution prohibits the establishment of a state religion. Regardless of whether I enter TRUE or FALSE, it always displays "Incorrect".
2. Question 2: Identify the name of this specific provision. Regardless of what I enter, it always displays "Incorrect".
__________________________________________________ __________
Code:
#include <stdio.h>
int main ()
{
int x;
char a;
char b[200];
char s[10];
char TRUE;
do
{
printf("WELCOME TO THE AMERICAN HISTORY INTERACTIVE QUIZ PROGRAM!!!\n");
printf("THIS SERIES IS ON THE U.S. CONSTITUTION.\n");
printf("THERE ARE 20 QUESTIONS IN TOTAL.\n");
printf("PLEASE ENTER A NUMBER IN THE RANGE 1-20,INCLUSIVE:\n");
printf("ENTER A NUMBER OUTSIDE THIS RANGE TO QUIT THIS PROGRAM.\n");
scanf("%d",&x);
switch (x)
{
case 1:
printf("What is the significance of Madison vs. Marbury?\n");
printf("a. The U.S. Supreme Court asserted its right to judicial review and transformed the power relationships between the executive, legislative, and the judicial branches.\n");
printf("b. The Judiciary Act of 1789 was found to be partially unconstitutional.\n");
printf("c. Marbury did not receive his political appointment in time.\n");
printf("d. Marbury never became a Justice of the Peace in the District of Columbia.\n");
scanf(" %c", &a);
if (a=='a')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 2:
printf("Which U.S. Constitutional amendment was ratified to ensure American women's voting rights?\n");
printf("a. 17th\n");
printf("b. 18th\n");
printf("c. 19th\n");
printf("d. 22nd\n");
scanf(" %c", &a);
if (a=='c')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 3:
printf("Which U.S. Constitutional amendment was ratified to mandate the direct election of U.S. Senators?\n");
printf("a. 16th\n");
printf("b. 17th\n");
printf("c. 18th\n");
printf("d. 19th\n");
scanf(" %c", &a);
if (a=='b')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 4:
printf("Which U.S. Constitutional amendment was ratified to ensure American women's voting rights?\n");
printf("a. 17th\n");
printf("b. 18th\n");
printf("c. 19th\n");
printf("d. 22nd\n");
scanf(" %c", &a);
if (a=='c')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 5:
printf("Who were the Anti-Federalists?\n");
printf("a. They opposed demands for a strong central government and instead supported strong states' rights and a federation of states.\n");
printf("b. They opposed the Federalists.\n");
printf("c. 19th\n");
printf("d. 22nd\n");
scanf(" %c", &a);
if (a=='c')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 6:
printf("What were some of the major weaknesses of the Articles of Confederation?\n");
printf("a. The U.S. Congress could not lay and collect taxes.\n");
printf("b. There was no national executive branch to enforce enacted legislation.\n");
printf("c. The U.S. Congress could not regulate interstate commerce.\n");
printf("d. All of the above.\n");
scanf(" %c", &a);
if (a=='d')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 7:
printf("Which amendment is the only one that has been repealed in American history?\n");
printf("a. 15th\n");
printf("b. 16th\n");
printf("c. 17th\n");
printf("d. 18th\n");
scanf(" %c", &a);
if (a=='d')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 8:
printf("What are the provisions of the Fifth Amendment?\n");
printf("I. Due process; freedom from self-incrimination; trials must be preceded by grand jury indictments;\n");
printf("II. Eminent domain\n");
printf("III. Double jeopardy\n");
printf("a. I only \n");
printf("b. II only \n");
printf("c. III only\n");
printf("d. I, II\n");
printf("e. I, II, III\n");
scanf(" %c", &a);
if (a=='e')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 9:
printf("What are the provisions of the Fifth Amendment?\n");
printf("I. Due process; freedom from self-incrimination; trials must be preceded by grand jury indictments;\n");
printf("II. Eminent domain\n");
printf("III. Double jeopardy\n");
printf("a. I only \n");
printf("b. II only \n");
printf("c. III only\n");
printf("d. I, II\n");
printf("e. I, II, III\n");
scanf(" %c", &a);
if (a=='e')
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
case 10:
printf("TRUE or FALSE.\n");
printf("The U.S. Constitution prohibits the establishment of a state religion.\n");
printf("Enter the answer:");
scanf("%s",&s);
if (s=="TRUE")
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
printf("Identify the name of this specific provision.\n");
printf("Enter the answer:");
scanf("%s", &b);
if (b=="Establishment Clause" || b=="Establishment")
printf("CORRECT!\n");
else
printf("INCORRECT!\n");
break;
}
} while (x>0 && x<21);
return 0;
}