Sunday, September 4, 2016


C Program To Determine If A Number Is A Multiple Of Another

Question: Write a program that reads in two integers and determines and prints whether the first is a multiple of the second. [Hint: Use the remainder operator.]
 * Website: 
 * Program to check if a number is a multiple of another number.

#include <stdio.h>
int main ( ){ 
    int num1, num2;
    printf("Enter two numbers: ");
    scanf("%d%d", &num1, &num2);
    if (num2 % num1 == 0){
       printf("%d is a multiple of %d\n", num1, num2);
    if (num2 % num1 != 0){
       printf("%d is not a multiple of %d\n", num1, num2);
    return 0;
Click here to see other solutions to Deitel C How To Program exercises.


  1. if num1 = 0, the result is undefined and will likely segfault

  2. This comment has been removed by the author.


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately. To get notified of replies or follow-up comments, click the box next to notify me.