Question

In: Computer Science

Im confused with this lab? 2.12 LAB: Divide by x Write a program using integers user_num...

Im confused with this lab?

2.12 LAB: Divide by x

Write a program using integers user_num and x as input, and output user_num divided by x three times.

Ex: If the input is:

2000
2
Then the output is:

1000 500 250

Solutions

Expert Solution

Answer-

Your code is given below in C language-

  • #include<stdio.h>
  • int main()
  • {
  •    int user_Num;   
  •    int x;   
  •    int i=1;
  •    printf("Enter the inputs:\n");
  •    scanf("%d%d",&user_Num,&x); //take input from user
  •    while(i<=3) //iterate the loop 3 times
  •    {
  •        user_Num = user_Num/x; //perform division
  •        printf("%d ",user_Num); //print the number
  •        i++; //increment the iteration varilable by 1
  •    }
  •    return 0;
  • }

Screenshot of running program and output-

Note- Please do upvote, if any problem then comment in box sure I will help.


Related Solutions

Write a program using integers usernum and x as input, and output usernum divided by x...
Write a program using integers usernum and x as input, and output usernum divided by x four times. You should prompt the user with the words: Enter the first integer: at which time the users enters a number, and then Enter the second integer: at which time the user enters the second number. The prompts must be EXACTLY as written, including the colon (:) character, or your test cases will fail. Since you are prompting the user for input, you...
Im working with visual basics for these problem. 1) Write a program that accepts five integers,...
Im working with visual basics for these problem. 1) Write a program that accepts five integers, and for each integer following the first, prints "GREATER" or "LESS" depending on whether or not the current integer is greater than the previous one. At the end, your application will let user know the largest and the smallest of the five numbers provided (BONUS): consider using the concepts of swapping the current and previous values as needed and don't use 5 variables.
8.26 LAB: Output numbers in reverse Write a program that reads a list of integers, and...
8.26 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5 2 4 6 8 10 the output is: 10 8 6 4 2 To achieve...
6.25 LAB: Swapping variables Write a program whose input is two integers and whose output is...
6.25 LAB: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 The output is: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order. def swap_values(user_val1, user_val2) **in Python, please
PYTHON: Im writing a program to make a simple calculator that can add, subtract, multiply, divide...
PYTHON: Im writing a program to make a simple calculator that can add, subtract, multiply, divide using functions. It needs to ask for the two numbers from the user and will ask the user for their choice of arithmetic operation 1- subtract 2- add 3- divide 4- multiply
Given a queue of integers, write an algorithm and the program in c++ that, using only...
Given a queue of integers, write an algorithm and the program in c++ that, using only the queue ADT, calculates and prints the sum and the average of the integers in the queue without changing the contents of the queue.
You are required to write an interactive program that prompts the user for two integers X...
You are required to write an interactive program that prompts the user for two integers X and Y and performs the following tasks: Adds two numbers Subtracts Y from X Multiplies X and Y Divides X by Y Finds which numbers is larger X oy Y) Prints all the results (a , b, c, d, and e) Program requirements: -     The program should run as many times as the users wish -     The program should be fully documented. -   ...
write these programs in c++ using getch() function Write a program that reads 20 integers from...
write these programs in c++ using getch() function Write a program that reads 20 integers from a user using a while loop and determines and prints whether each of those integers is an even number. Write a program that uses a while statement to read integers from a user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters -1.
1- Write a program that will display the following series of integers using iterative statement of...
1- Write a program that will display the following series of integers using iterative statement of your choice, and terminate the iteration once it is larger than 200. 1, 3, 7, 13, 21, 31, 43, … use only C++!!
***C++ Coding*** Write a program for sorting a list of integers in ascending order using the...
***C++ Coding*** Write a program for sorting a list of integers in ascending order using the bubble sort algorithm. Please include comments to understand code. Requirements Implement the following functions: int readData( int **arr) arr is a pointer to pointer for storing the integers. The function returns the number of integers. The function readData reads the list of integers from a file call data.txt into the array arr. The first integer number in the file is the number of intergers....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT