Question: (Write a program, and show the output too ) C programming You will be writing a simple Bee application. There are five questions. The application
(Write a program, and show the output too) C programming
You will be writing a simple Bee application. There are five questions. The application will display question 1, wait for the user to type a response, it checks if it is correct or not. if correct, it will increment the score by one. otherwise, it will go ahead with the next question. This is repeated for four other questions.
TASK1 : You will be writing all five questions each in a separate function.
For instance, take this question 1 written in a function
:
int Question_1 ( )
{
printf ( "What is the capital of USA ? 1. Atlanta 2. Washington DC 3. New York 4. Chicago " ) ;
int correctAnswer = 2 ;
int userResponse ;
scanf ( "%d", &userResponse ) ;
if ( correctAnswer == userResponse )
return 1
else
return 0
}
okay? Continue creating four functions for four other questions. The correct answer for each is given to you.
Question_2 is
Where is Louisiana
1. Canada
2. France
3. USA
4. Mexico
correctAnswer = 3
Question_3 is
What is the capital of United Kingdom
1. London
2. Scotland
3. Birmingham
4. Heathrew
correctAnswer = 1
Question_4 is
What is the capital of New York
1. Syracuse
2. Albany
3. Buffalo
4. New York City
correctAnswer = 4
Question_5
Where is Los Angeles
1. California
2. San Diego
3. Nevada
4. Utah
correctAnswer = 1
Now the main function would like, I have coded for question 1, you repeat for next 4 questions . Test it out.
main ( )
{
int score = 0 ;
int x = Question_1 ( ) ;
if ( x == 1 ) print good job, increment a score by one ;
else
print sorry
//similarly repeat for other four questions.
// repeat for question 2,
// question 3
// question 4
// question 5
// we are done with all five questions, now
//print the score.
Total Points = 5
Your score = print score
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
