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
The function below takes one parameter: a string (date_string) containing a date in the mm/dd/year format. Complete the function
Natalija [7]

Answer:

The solution code is written in Python 3.

  1. def convertDate(date_string):
  2.    date_list = date_string.split("/")
  3.    for i in range(0, len(date_list)):
  4.        date_list[i] = int(date_list[i])
  5.    return date_list  
  6. print(convertDate('06/11/1930'))

Explanation:

Firstly, create a function convertDate() with one parameter, <em>date_string</em>. (Line 1).

Next, use the Python string <em>split()</em> method to split the date string into a list of date components (month, day & year) and assign it to variable <em>date_list</em>. (Line 3) In this case, we use "/" as the separator.

However, all the separated date components in the <em>date_list</em> are still a string. We can use for-loop to traverse through each of the element within the list and convert each of them to integer using Python<em> int() </em>function. (Line 5 - 6)

At last return the final date_list as the output (Line 8)

We can test our function as in Line 11. We shall see the output is as follow:

[6, 11, 1930]

8 0
2 years ago
Intranets: a. are based on mainframe technology. b. provide the platform on which a firm builds its information systems. c. are
antoniya [11.8K]

Answer: Option (e) is correct

Explanation:

Intranet is the private network that is created for sharing information and data ,handle computing facilities, sharing files etc through internet service within a organization. Members of the company can access this technology for performing activities on the network.

  • Other options are incorrect because numerous networks are not linked ,does not share information outside organization, does not act as information system's base and neither is linked with mainframe technology.
  • Thus,the correct option is option(e).
5 0
3 years ago
Which job role requires you to create user guides for computer products and services?
kipiarov [429]

For plato I think technical writer is the answer.

Technical writer: As a technical writer, you’ll create user manuals and support guides for a number of computer products and services. You may also develop content to market technical products online.

4 0
3 years ago
Read 2 more answers
Pls help I will mark you the brainliest
ehidna [41]

Answer:

c

Explanation:

6 0
3 years ago
Read 2 more answers
What mode is generally used when delivering a presentation to an audience?
dybincka [34]

Answer:

delivery mode

Explanation:

there it is

7 0
3 years ago
Read 2 more answers
Other questions:
  • Your friend sends you a photograph of his son. you want to enlarge the photograph. which program type will you use to make this
    15·1 answer
  • What is the name of the organization responsible for assigning public ip​ addresses?
    13·1 answer
  • Can someone help me with...A table can help? PLEASE
    8·1 answer
  • Need help writing a program that reads a string if the option "E" (enter a string) is chosen, and checks if parentheses (), brac
    14·1 answer
  • 5. Drawing Conclusions If you were a person in
    10·1 answer
  • While designing your network's VLAN topology, your team has decided to use a centrally managed DHCP server rather than creating
    8·1 answer
  • You are running out of storage space on one of your servers. you need to purchase an external hard drive, as there are no drive
    8·2 answers
  • Radar devices are used by law enforcement to be sure that individuals are driving safely. They tell the officer how fast the veh
    12·1 answer
  • Which terms means device that converts one voltage to another ?
    15·1 answer
  • Do you guys answer questions about cyber security?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!