Friday, October 14, 2011

Write a program to do the following: a. Output of the question is: Who was the winner of 2007 cricket world cup? b. Accept answer c. If answer is correct print good and stop otherwise give output message as answer is wrong, so try again. d. Display the correct answer when the answer is wrong even at the third attempt.

#include
#include
main()
{
int i=1;
do
{
char a[100];
printf("Who is the winner of 2007 cricket world cup\t:");
scanf("%s",a);
if (strcmp(a,"australia")==0||strcmp(a,"AUSTRALIA")==0||strcmp(a,"Australia")==0)
{
printf("Right Answer\n");
break;
}
else if(i<=2 && strcmp(a,"australia")!=0 && strcmp(a,"AUSTRALIA")!=0&&strcmp(a,"Australia")!=0)
printf("Sorry,Wrong Anser try again\n");
else if(i==3 && strcmp(a,"australia")!=0 && strcmp(a,"AUSTRALIA")!=0&&strcmp(a,"Australia")!=0)
{printf("\nThis time also you entered wrong answer\n\n");
printf("\n\t\t\tCorrect Answer is : Australia \n\n");
}
}
while(i++ && i<4);
}

No comments:

Post a Comment