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

Write a quiz program that helps a student learn the multiplication operation. A series of questions are asked, such as: What is 12 mod 5?Note: the numbers 12 and 5 were randomly generated by your program. After the user types in their answer, print a suitable message to the screen. The game ends after 4 wrong answers.

Solutions

Expert Solution

quiz.c

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
   // random seed
   srand(time(0));
   int a, b, answer,wrong=0;
   // Ierate until 4 wrongly answered
   while(wrong!=4)
   {
       // Generate a number from [1,100]
       a = rand()%100+1;
       // Generate a number from [1,10]
       b = rand()%10+1;
       // Printing to screen
       printf("%d mod %d = ",a,b);
       // Get answer from user
       scanf("%d",&answer);
       // If answer is correct
       if(a%b==answer)
       {
           printf("Correct answer\n");  
       }  
       // If answer is wrong
       else
       {
           printf("Wrong answer\n");
           wrong++;
       }
   }
   return 0;
}

output screenshot:


Related Solutions

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...
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)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT