Thursday, March 15, 2012

Multiples

Function multiple determines for a pair of integers whether the second integer is the the multiple of the first.
/*
   title: multiples
   author: aeriqusyairi
   date: Jan23 2012
   note: determine whether the second integer is
         the multiple of the first integer
*/
#include<stdio.h>

int multiple(int, int);

int main(){
   int a = 0, b = 0, c = 0;
    
   printf("Input 2 integer...\n1:");
   scanf("%d", &a);
   printf("2:");
   scanf("%d", &b);
   
   c = multiple(a, b);
   
   if(c == 1)
      printf("%d is a multiple of %d\n", b, a);
   else if(c == 0)
      printf("%d is not a multiple of %d\n", b, a);
      
   system("pause");
   return 0;   
}

int multiple(int first, int second){
   if(second % first == 0)
      return 1;
   else
      return 0;     
}

No comments:

Post a Comment