1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GrogVix [38]
2 years ago
12

Write a program that outputs a subtraction practice problem for a student, outputting the larger random number

Computers and Technology
1 answer:
PolarNik [594]2 years ago
5 0

Answer:

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main(void)

{

   srand(time(NULL));

   int num1, num2;

   int val;

   while (true)

   {

       num1 = rand() % 100 + 1; //Random number between 1-100

       num2 = rand() % 100 + 1; //Random number between 1-100

       if (num1 >= num2)

       {

           printf("%d - %d = ", num1, num2);

           scanf("%d",&val);

           if (val == num1-num2)

           {

               printf("Correct!\n");

           }

           else

           {

               printf("Incorrect!\n");

           }    

       }

       else

       {

           printf("%d - %d = ", num2, num1);

           scanf("%d",&val);

           if (val == num2-num1)

           {

               printf("Correct!\n");

           }

           else

           {

               printf("Incorrect!\n");

           }

       }    

   }

}

Explanation:

First, we create two random numbers and save the values.  Then we check to see which value is larger.  Based on that, we change how we display the format to the user.  Then we check to see if the user input number is equivalent to the subtraction problem.  If it is, we display Correct!  Else, we display Incorrect!

Cheers.

You might be interested in
En que se diferencia el software y el hardware
bazaltina [42]

Answer:

El hardware de la computadora es cualquier dispositivo físico utilizado en o con su máquina, mientras que el software es una colección de código instalado en el disco duro de su computadora. Por ejemplo, el monitor de la computadora que está usando para leer este texto y el mouse que está usando para navegar por esta página web son hardware de computadora.

Explanation:

8 0
3 years ago
Read 2 more answers
At Greenwood ATCT, arrival information need NOT be forwarded while FDIO is operational unless the sequence of aircraft changes a
GuDViN [60]

The available options are:

A. Arrival time differs by more than 3 minutes

B. Aircraft is issued an approach other than the tower specified

C. Verbal coordination has not been yet accomplished

Answer:

Aircraft is issued an approach other than the tower specified

Explanation:

Considering the situation described in the question, and according to Instrument Flight Rules (IFR), Approach Clearance Procedures, when at Greenwood Air Traffic Control Tower (ACTC), arrival information need not be forwarded while Flight Data Input-Output (FDIO) operational unless the sequence of aircraft changes and the "Aircraft is issued an approach other than the tower specified."

3 0
2 years ago
Create a function that takes an integer array as input and a value and returns a POINTER to the number of times the value appear
suter [353]

Answer:

An array is a fundamental data structure built into C. A thorough understanding of arrays and their use is necessary to develop effective applications.

6 0
2 years ago
Full form of http.<br>wrong answer will be reported ​
vodomira [7]

Answer:

So it is Hyper Text Transfer Protocol.

Hope it helps

6 0
2 years ago
Read 2 more answers
What is the correct keyboard shortcut to cut a cell value
vladimir2022 [97]

Answer:

Cntrl+X

Explanation:

Do it on your computer

4 0
2 years ago
Other questions:
  • How can i add card reader to pc answers?
    9·1 answer
  • Which of the following is an example of a logic bug?
    8·1 answer
  • Write a program that uses these bounds and bisection search (for more info check out the Wikipedia page on bisection search) to
    8·1 answer
  • You have developed a prototype of a software system and your manager is very impressed by it. She proposes that it should be put
    5·1 answer
  • What two pieces of information would you need in order to measure the masses of stars in an eclipsing binary system?
    9·1 answer
  • Fill in the blank: _________ is Google’s machine-learning artificial intelligence system that interprets people’s searches to fi
    9·1 answer
  • What is the name for the size and style of text?
    8·2 answers
  • What is computer assisted translation​
    9·1 answer
  • If you want to remove the autocorrect options button from the screen, you can press the ____ key.
    15·1 answer
  • given 2,4,3,-1 as input, what is the output for the following program:total_product = 1 user_value = int(input()) while user_val
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!