I am a beginner in programming. I am using Dev C++ and there is a bug. Can anyone help me to find out...
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<windows.h>
#include <time.h>
void main()
{
printf("Welcome to MCQs Test.\nPhysics CH # 1\nExercise MCQs......\nChoose the correct answer.\n\n");
char ans;
int true = 0, false = 0, count = 0;
printf("1) Which of the following is an example of Simple Harmonic Motion?\n\n");
printf("A. Motion of a simple pendulum\nB. The motion of ceiling fan\nC. The spinning of the Earth around its axis\nD. A bouncing ball on a floor\n\n");
printf("Select your answer (a, b, c, d): ");
scanf("%c", &ans);
if(ans == 'a'){
printf("\nCorrect ^_^\n\n");
true++;
} else if(ans != 'a'){
printf("\nOops! Your answer is Wrong.\nThe Correct answer is: \'A. Motion of a simple pendulum\' \nBetter luck Next time....\n\n");
false++;
}
count++;
printf("Press any key to continue...\n\n");
getch();
printf("2) If the mass of the bob of a pendulum is increased by a factor of 3, the period of the pendulum`s motion will\n\n");
printf("A. be increased by a factor of 2\nB. remain the same\nC. be decreased by a factor of 2\nD. be decreased by a factor of 4\n\n");
printf("Select your answer (a, b, c, d): ");
scanf("%c", &ans);
if(ans == 'b'){
printf("\nCorrect ^_^\n\n");
true++;
} else if(ans != 'b'){
printf("\nOops! Your answer is Wrong.\nThe Correct answer is: \'B. remain the same\' \nBetter luck Next time....\n\n");
false++;
}
count++;
printf("Press any key to continue...\n\n");
getch();
printf("%d of your answers is/are correct while %d is/are incorrect out of %d Questions\n", true, false, count);
printf("Press any key to continue...\n\n");
getch();
}
The output is:
Welcome to MCQs Test.
Physics CH # 1
Exercise MCQs......
Choose the correct answer.
1) Which of the following is an example of Simple Harmonic Motion?
A. Motion of a simple pendulum
B. The motion of ceiling fan
C. The spinning of the Earth around its axis
D. A bouncing ball on a floor
Select your answer (a, b, c, d): a
Correct ^_^
Press any key to continue...
2) If the mass of the bob of a pendulum is increased by a factor of 3, the period of the pendulum`s motion will
A. be increased by a factor of 2
B. remain the same
C. be decreased by a factor of 2
D. be decreased by a factor of 4
Select your answer (a, b, c, d):
Here is the actual problem as it is not taking any input and just showing the result.
Oops! Your answer is Wrong.
The Correct answer is: 'B. remain the same'
Better luck Next time....
Press any key to continue...
1 of your answers is/are correct while 1 is/are incorrect out of 2 Questions
Press any key to continue...