Im almost done writing this code, but i cant get it to stop on the 2nd or 4th question to take an input. Any suggestions?
Code:
#include<stdio.h>
int main()
{
int ch=1,i;
while(ch==1)
{
printf("\n1: What is the correct value to return to the operating system upon the successful completion of a program\nA. -1 \nB. 1 \nC. 0 \nD. Programs do not return a value.");
printf("\nEnter Your choice:");
char ch1;
scanf("%c",&ch1);
if((ch1=='C')||(ch1=='c'))
{
i++;
printf("\ncorrect answer");
}
else
{
printf("\nIn Correct Answer");
}
printf("\n2: What is the only function all C programs must contain\nA. start()\nB. system()\n C. main()\n D. program()\n");
printf("\nEnter Your choice:");
char ch2;
scanf("%c",&ch2);
if((ch2=='C')||(ch2=='c'))
{
printf("\ncorrect answer");
i++;
}
else printf("\nIn Correct Answer");
printf("\n3: What punctuation is used to signal the beginning and end of code blocks\nA. { } \nB. -> and <- \nC. BEGIN and END \nD. ( and )");
printf("\nEnter Your choice:");
char ch3;
scanf("%c",&ch3);
if((ch3=='A')||(ch3=='a'))
{
printf("\ncorrect answer");
i++;
}
else printf("\nIn Correct Answer");
printf("\n4: What punctuation ends most lines of C code\nA. . \nB. ; \nC. : \nD. ' ");
printf("\nEnter Your choice:");
char ch4;
scanf("%c",&ch4);
if((ch4=='B')||(ch4=='b'))
{
printf("\ncorrect answer");
i++;
}
else printf("\nIn Correct Answer");
printf("\n5: Which of the following is a correct comment?\nA. */ Comments */\nB. ** Comment **\nC. /* Comment */\nD. { Comment }");
printf("\nEnter Your choice:");
char ch5;
scanf("%c",&ch5);
if((ch5=='C')||(ch5=='c'))
{
printf("\ncorrect answer");
i++;
}
else printf("\nIn Correct Answer");
printf("score is ....%d",i);
printf("Enter 1 to retake the quiz");
scanf("%d",&ch);
}
return 0;
}