Sunday, September 4, 2016

// // Leave a Comment

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.]
/* 
 * Author: AGHATISE OSAZUWA
 * Website: www.cscprogrammingtutorials.com 
 *
 * 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.

0 comments:

Post a Comment


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.

Thanks.