Question

In: Computer Science

I WANT THIS CODE TO BE SIMPLE BECAUSE I AM NEW TO CODING AND I WANT...

I WANT THIS CODE TO BE SIMPLE BECAUSE I AM NEW TO CODING AND I WANT TO KNOW THE DETAILS! straight C Program. write a quiz game where a number of questions are asked and the user will win each time he answers right. and he loses each time he answers wrong.

the type of questions asked can be about sports or anything else. You can put 5 quiz questions.

It should only include the following: #include <stdio.h> and #include <stdlib.h>

because it is a simple code.

Solutions

Expert Solution

plss give like if u like answer. any question free to ask.

#include<stdio.h>
#include<stdlib.h>

int main()
{
    char ans1,ans2,ans3,ans4,ans5;      //Taking character variable for every questions correct answers.
    char yans1,yans2,yans3,yans4,yans5; //Taking character variable for your answers
    printf("Welcome to Quiz/n/n");
    printf("Holkar trophy associated with which trophy?\n\n"); //"\n\n use for skip next two line
    printf("A.Bridge\tB.Hockey\n\nC.Football\tD.Badminton\n\n");
    ans1='A'; //here we store the correct answer of question.
    printf("Your Answer:");
    scanf(" %c",&yans1); //must use space before %c otherwise next scanf will not work.
    if( ans1 == yans1) //compare correct answer with your answer.
    {
        printf("\nYou Win\n\n"); //if ans correct it show you win.
    }
    else
    {
        printf("\nYou Lose\n\n"); //if ans wrong it show you lose.
    }
    //same way we can do for other questions.

    printf("With which game does Davis cup associated?\n\n");
    printf("A.Table Tennis\tB.Hockey\n\nC.Polo\tD.Lawn Tennis\n\n");
    ans2='D';
    printf("Your Answer:");
    scanf(" %c",&yans2);
    if(ans2 == yans2)
    {
        printf("\nYou Win\n\n");
    }
        else
    {
        printf("\nYou Lose\n\n");
    }
    printf("Who is the first indian women to win an Asian Games gold in 400m run?\n\n");
    printf("A.M.L Valsamma\tB.P.T. Usha\n\nC.kamaljit Sandhu\tD.K.Malleshwari\n\n");
    ans3='B';
    printf("Your Answer:");
    scanf(" %c",&yans3);
    if( ans3 == yans3)
    {
        printf("\nYou Win\n\n");
    }
        else
    {
        printf("\nYou Lose\n\n");
    }
    printf("Term chinaman is related to which sport?\n\n");
    printf("A.Football\tB.Hockey\n\nC.Golf\tD.Cricket\n\n");
    ans4='D';
    printf("Your Answer:");

    scanf(" %c",&yans4);

    if( ans4 == yans4)
    {
        printf("\nYou Win\n\n");
    }
        else
    {
        printf("\nYou Lose\n\n");
    }
    printf("Welling Trophy is related to which game?\n\n");
    printf("A.Rowing\tB.Hockey\n\nC.Tennis\tD.Polo\n\n");
    ans5='A';
    printf("Your Answer:");
    scanf(" %c",&yans5);
    if( ans5 == yans5)
    {
        printf("\nYou Win\n\n");
    }
        else
    {
        printf("\nYou Lose\n\n");
    }

    return 0;
}


Related Solutions

I am using NetBeans IDE Java for coding. I would like the code to be commented...
I am using NetBeans IDE Java for coding. I would like the code to be commented for a better understanding. 1. Implement a class Robot that simulates a robot wandering on an infinite plane. The robot is located at a point with integer coordinates and faces north, east, south, or west. Supply methods: public void turnLeft() public void turnRight() public void move() public Point getLocation() public String getDirection() The turnLeft and turnRight methods change the direction but not the location....
I am using NetBeans IDE Java for coding. I would like the code to be commented...
I am using NetBeans IDE Java for coding. I would like the code to be commented for a better understanding. 1. Implement a class Robot that simulates a robot wandering on an infinite plane. The robot is located at a point with integer coordinates and faces north, east, south, or west. Supply methods: public void turnLeft() public void turnRight() public void move() public Point getLocation() public String getDirection() The turnLeft and turnRight methods change the direction but not the location....
Simple code for a game on C coding.
Simple code for a game on C coding.
Write assembler code to print even numbers from 1-20. Submit code and screenshot. I am coding...
Write assembler code to print even numbers from 1-20. Submit code and screenshot. I am coding in NASM on a SASM system.
Python Coding Question (Data Science) Hello I am having difficulty writing a code in python to...
Python Coding Question (Data Science) Hello I am having difficulty writing a code in python to do a specific task. I have two text files, Positive.txt and Practice_forhw1.txt. I want to write a script that will check if any words in Practice_forhw1.txt match any of the words in Positive.txt then the word would get replaced with a "+1" in the Practice_forhw1.txt and then print out the Practice_forhw1.txt.  (i.e if the word "happy" is in both Positive.txt and Practice_forhw1.txt then I want...
Write a simple code for a simple connect the dots game in plain C coding.
Write a simple code for a simple connect the dots game in plain C coding.
please write simple python3 program and also explain the logic of program because i am not...
please write simple python3 program and also explain the logic of program because i am not understanding and crying so much Problem Statement There is a very famous old restaurant in ByteLand city,which can serve only 1 customer at any given time.It has B chairs outside for waiting customers.The restautants manager has a list of people who will be coming in today.The i-th customer will arrive at t[i] (all unique) time and will eat for d[i] unit of time.The restaurant...
I am using NetBeans IDE Java to code and I am seeking comment to the code...
I am using NetBeans IDE Java to code and I am seeking comment to the code as well (for better understanding). Magic squares. An n x n matrix that is filled with the numbers 1, 2, 3, …, n2 is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value. Write a program that reads in 16 values from the keyboard, displays them in a 4...
I am new to socket programming and I wish to know what these lines of code...
I am new to socket programming and I wish to know what these lines of code do. I know they are creating UDP sockets, but it would help if someone explained what the code means. Thank you. Python Code: import socket testingSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) testingSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, testingSocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) testingSocket.bind(('0.0.0.0', 50000)) send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) send_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) receiving_thread = Thread(target=self.receivingFunction) send_thread = Thread(target=self.sendMessage) broadcast_online_status_thread = Thread(target=onlineStatus)
As a new nurse, I am most frightened of messing up a medication order. I want...
As a new nurse, I am most frightened of messing up a medication order. I want to work in a Medical Intensive Care Unit, which is one of the most high stress jobs there is in nursing, in my opinion. Although I know I can handle the stress, I am terrified of giving someone the wrong dose of their medication. But, it is a good thing I am extremely organized and rewrite almost everything whenever someone gives me information. I...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT