new to programming. can't get this if else statement to work properly. please help!
The printf statement is not working.
Code:
#include <stdio.h>
main()
{
int num; /* the number for the table */
int answer; /* the answered number */
int correctans; /* the correct answer */
int table_counter; /* counts the number of tables attempted */
int counter; /* increments the question! */
int counter2; /* increments 1 errors */
int counter3; /* increments 2 errors */
table_counter=0; /* sets number of tables attempted to zero */
counter=2; /* sets table number to zero */
counter2=0; /* sets '1 errors' to zero */
counter3=0; /* sets '2 errors' to zero */
printf("\tWelcome to the Multiplication Tutorial.\n\n");
do
{
printf("\t\tPlease select a table: ");
scanf("%d",&num);
table_counter++;
printf("\n\n\tYou have selected the %d times able.",num);
do
{
printf("\n\tWhat is %d times %d ?: ",num,counter);
scanf("%d",&answer);
correctans=num*counter;
{
if (correctans==answer)
{
printf("\t\t\t\tCorrect.");
}
else
{
if (correctans!=answer)
{
printf("\t\t\t\tThat is not correct, please try again.");
printf("\n\tWhat is %d times %d ?: ",num,counter);
scanf("%d",&answer);
correctans=num*counter;
}
else
{
if (correctans==answer)
{
printf("\t\t\t\tCorrect.");
counter2++;
}
else
{
if (correctans!=answer)
{
printf("\t\t\t\tThat is not correct. The answer is %d.",correctans);
counter3++;
}
}
}
}
}
counter++;
}
while (counter <= 12);
counter=2;
}
while (num > 0);
return 0;
}
The code compiles, however, the printf staements highlighted in blue won't print.
Why?