I am trying to figure out how I'm supposed to write a piece of code which tells my whether a number is whole or not when divided by a second number.
I am fairly new to programming, but I do have a lot of experience in web design and scripting so I'm not a total beginner and have a good understanding of the concepts involved.
For example:
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- int main() {
- int number1 = 20;
- int number2 = 25;
- int divisor = 2;
- if(number1/divisor == #Whole Number#){
- printf("Result 1 is an integer\n");
- }else{
- printf("Result 1 is not an integer\n");
- }
- if(number2/divisor == #Whole Number#){
- printf("Result 2 is an integer\n");
- }else{
- printf("Result 2 is not an integer\n");
- }
- return 0;
- }
Expand|Select|Wrap|Line Numbers
- Result 1 is an integer
- Result 2 is not an integer