Writing a Program to Divide Numbers - Help Needed

In summary, Dan is looking for help in writing a program that can take a number and divide it by a list of other numbers, returning the results with remainders. He is using a '94 version of C++ and is looking for assistance with resetting the program and printing values above 250,000. It is recommended that he review the manual for C++ to better understand the language before attempting the task. Once he has done so, the job should only take a few minutes to complete.
  • #1
carterw
5
0
Hello.

I would like to write a program into which I can input any number, say 11133, and divide this by a list of numbers, say 543, 345, 2368...
and have the program print the list of results, integers only, with the remainder.

I imagine this is a fairly simple program to write, but I am still unfamiliar as yet with what steps to take to begin. Would anyone be able to help. Thanks in advance.

Dan
 
Computer science news on Phys.org
  • #2
First, select a language.

- Warren
 
  • #3
Hi Warren,

Thanks,
I have started using a '94 version of C++,
are you familiar with this?
I managed to get a useful program working.

Two problems though that I have not been able to find solutions to yet.

1) How do i get it so the program resets at the press of a button so I don't have to keep exiting and entering again?

2) Even though I am using "long" integers throughout, the program will not print values better than about 250 000. beyond this I just get garbled data.

Thanks,
Dan
 
  • #4
carterw,

If C++ is your language of choice and you don't have a manual explaining the coding requirements, then I would recommend that you do that first. You don't have to read the book from cover to cover, but, understand the overall methodology of the language and focus on the sections that address the specific functions you need. Anytime spent learning a language such as an all purpose tool like C++, is time well spent.

You are right. Once you review the manual, this job should take only a few minutes to complete.
 
Last edited:

1. How do I start writing a program to divide numbers?

To start writing a program to divide numbers, you first need to decide which programming language you want to use. Then, familiarize yourself with the syntax and basic concepts of that language. Next, plan out the steps needed to divide numbers, such as getting user input, performing the division operation, and displaying the result. Finally, begin writing your code using the chosen programming language.

2. What is the logic behind dividing numbers in a program?

The logic behind dividing numbers in a program is to perform the division operation by using the appropriate mathematical operator. This is done by taking the first number (dividend) and dividing it by the second number (divisor). The result is the quotient, which is the answer to the division problem.

3. Can you provide an example of a program to divide numbers?

Yes, here is an example of a program to divide two numbers in Python:

num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
result = num1 / num2
print("The result of dividing", num1, "by", num2, "is", result)

This program gets two numbers from the user, divides them, and displays the result.

4. How can I handle division by zero in my program?

Division by zero is not allowed in mathematics and programming. You can handle this situation in your program by adding a conditional statement to check if the divisor is equal to zero. If it is, you can display an error message or prompt the user to enter a different number.

5. Are there any resources or tools that can help me write a program to divide numbers?

Yes, there are many resources and tools available to help you write a program to divide numbers. Online tutorials, forums, and coding communities can provide guidance and support. You can also use an integrated development environment (IDE) like PyCharm, Visual Studio, or Eclipse, which offer features such as code completion and debugging to make writing and testing your code easier.

Similar threads

  • Computing and Technology
Replies
9
Views
1K
Replies
5
Views
2K
  • Programming and Computer Science
2
Replies
49
Views
3K
  • STEM Academic Advising
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
22
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • STEM Academic Advising
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
985
  • STEM Career Guidance
Replies
3
Views
1K
  • Programming and Computer Science
Replies
32
Views
2K
Back
Top