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
julsineya [31]
3 years ago
8

In this lab you are asked to declare two variables of type integer: userNum and x. The user should input should be stored using

scanf statements. Then you are asked to divide the value for userNum by x three times(three different operations). Each time you do the division, assign the value to userNum overwriting the previous value and print it out using a print statement. Do this three times. In this case there is only one new line print statement at the end.
#include
int main(void) {
int x;
int userNum;
scanf("%d %d" , &userNum, &x);
userNum = (double)userNum / x;
printf("%d " , userNum);
userNum = (double)userNum / x;
printf("%d " , userNum);
userNum = (double)userNum / (double)x;
printf("%lf\n" , (double)userNum);
return 0;
}
my input is 100 2
my output is 50 25 12.000
8 months ago
Computers and Technology
1 answer:
AVprozaik [17]3 years ago
6 0

Answer:

See Explanation

Explanation:

Your program is correct and it follows the correct sequence; however, the reason you keep getting integer result is because the question requires that you declare both variables as integer.

The only modification required in your program is to change change #include to #include <stdio.h> for the program to be free of error.

You might be interested in
What does the following code print?
Crank

Answer:

It throws an error.

the public class needs a name.

like this:

public class G{ public static void main(String[] args) {

   int x=5 , y = 10;

   if (x>5 && y>=2) System.out.println("Class 1");

   else if (x<14 || y>5) System.out.println(" Class 2");

   else System.out.println(" Class 3"); }// end of main

   }

if you give the class a name and format it, you get:

Class 2

Explanation:

3 0
3 years ago
Illustrator : how do you edit a swatch ?​
allsm [11]

Answer:

To edit an existing pattern, double-click the pattern in the pattern swatch, or select an object containing the pattern and choose Object > Pattern > Edit Pattern

4 0
3 years ago
Which of the following is considered a modern method of communication?
Vika [28.1K]
The answer is C. Tablet, because that is the quickest, easiest, and most recent way of communication.
4 0
3 years ago
Read 2 more answers
A piece of data in a program whose value can change is called a(n) -
Arada [10]

Answer:

it is b variable

Explanation:

7 0
2 years ago
Read 2 more answers
:(.
AnnZ [28]

Answer:

Um what?

Explanation:

Chile anyways so-

7 0
3 years ago
Read 2 more answers
Other questions:
  • To type the letter address, _________ space from the dateline
    9·2 answers
  • A drop-down menu must be contained by
    5·1 answer
  • To make sure that you do not get too tired when typing for long periods, how often should you get up and stretch? Every 15 minut
    9·1 answer
  • Which type of computer network ensures high quality​
    9·1 answer
  • relational integrity constraints are rules that enforce basic and fundamental information-based constraints. True or False
    9·1 answer
  • Processor is used to process the data.<br>A)true <br>B)False​
    13·1 answer
  • Which picture should i put as my profile picture.
    15·2 answers
  • Which of these is a valid use of the Reply All feature?
    11·1 answer
  • Which option is the primary means of communication for coauthors working on PowerPoint presentations?
    10·1 answer
  • What are the paparazzi?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!