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]
3 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]3 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
What method do phishing and spoofing scammers use
Leya [2.2K]

Answer:

please give me brainlist and follow

Explanation:

There are various phishing techniques used by attackers:

Installing a Trojan via a malicious email attachment or ad which will allow the intruder to exploit loopholes and obtain sensitive information. Spoofing the sender address in an email to appear as a reputable source and request sensitive information.

8 0
2 years ago
Choose the correct answer base on the Components of Computer System
kondor19780726 [428]
1 - b - Excel is a computer program, so it'd be Software
2 - a - Process of elimination, haven't heard of the term 'peopleware' before.
3 - d - A joystick accepts input from a user to interact with a computer. ex. Flight Simulators
4 - c - A monitor will display (or output) an image based on what is received from the computer.
4 0
3 years ago
What natural resources products are discussed in the article? Are they renewable or nonrenewable?
Alex

Where is the article

4 0
3 years ago
Read 2 more answers
Implement a Java program that creates math flashcards for elementary grade students. User will enter his/her name, the type (+,
jeka57 [31]

import java.util.Scanner;

public class JavaApplication44 {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.print("Enter you name: ");

       String name = scan.nextLine();

       System.out.print("Enter your operation (+,-,*,/): ");

       String operator = scan.nextLine();

       System.out.print("Enter the range of the problems: ");

       int ran = scan.nextInt();

       System.out.print("Enter number of problems: ");

       int problems = scan.nextInt();

       int score = 0;

       for (int i = 1; i <= ran; i++){

           int first = (int)(Math.random()*ran);

           int sec = (int)(Math.random()*ran);

           System.out.print("Problem #"+i+": "+first + " "+operator+" "+sec+" = ");

           int ans = scan.nextInt();

           if (operator.equals("+")){

               if (ans == first + sec){

                   System.out.println("Correct!");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first+sec));

               }

           }

           else if(operator.equals("-")){

               if (ans == first - sec){

                   System.out.println("Correct");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first - sec));

               }

           }

           else if (operator.equals("*")){

               if (ans == first * sec){

                   System.out.println("Correct");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first * sec));

               }

           }

           else if (operator.equals("/")){

               if (ans == first / sec){

                   System.out.println("Correct");

                   score++;

               }

               else{

                   System.out.println("Wrong. The correct answer is "+(first / sec));

               }

           }

           

       }

       System.out.println(name+", you answered "+score+" questions correctly.");

   }

   

}

I hope this helps!

8 0
3 years ago
In a digital drawing program, when an object is highlighted, boxes appear at the sides and corners. These boxes can be grabbed a
LenKa [72]

Pointers can be used to manipulate the size and shape of the object.

Answer: Option 2.

<u>Explanation:</u>

Digital drawing is the point at which a drawing is made utilizing designs programming. Rather than utilizing a pencil and paper, advanced craftsmen draw with a tablet or a PC, alongside a gadget, for example, a mouse or a stylus.

Drawing digitally makes it simpler to pick hues and change them and their levels with a basic snap of your mouse. To put it plainly, advanced workmanship lets you change your canvases without demolishing them and also change the shape and size of the objects easily.

8 0
3 years ago
Other questions:
  • These systems consist of interlinked knowledge resources, databases, human experts, and artificial knowledge agents that collect
    9·1 answer
  • Explain Cascading Style Sheets and what they do. Describe their primary function, two effects that this function has on programm
    11·1 answer
  • Charles would like to move his internet browser window so that he can see his desktop.He should
    5·1 answer
  • Multiply 1101 and 0110 in binary.
    10·1 answer
  • Two of the major sources used today for obtaining information to create computer maps are satellites and _____________.
    11·2 answers
  • How are special characters added to a Word document? Check all that apply.
    6·2 answers
  • What will you see on the next line?
    6·2 answers
  • Which symbol would be used in a flowchart to represent a connection to another part of the flowchart on the same page
    15·1 answer
  • 16. If a user can make modifications to database objects, what permission has that
    13·1 answer
  • A _______ attack uses software to try thousands of common words sequentially in an attempt to gain unauthorized access to a user
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!