• 0

Write a function multiple that determines for a pair of integers whether the second integer is a mul


Question

Write a function multiple that determines for a pair of integers whether the second integer is a multiple of the first. The function should take two integer arguments and return true if the second is a multiple of the first, false otherwise. Use this function in a program that inputs a series of pairs of integers.

 

 my answer true or false :) 

 

#include <iostream>

using namespace std;

int multiple( int, int );

 

 int main()

 {

   int x, y;

   for ( int i = 1; i <= 3; ++i ) {

      cout << "Enter two integers: ";

       cin >> x >> y;

          if ( multiple( x, y ) )

          cout << y << " is a multiple of " << x << "\n\n";

       else

          cout << y << " is not a multiple of " << x << "\n\n";

    }

 

    cout << endl;

 

    return 0;

 }

 

int multiple( int a, int b )

 {

    return !( b % a );

 } 

2 answers to this question

Recommended Posts

  • 0

Write a program that reads in a line of text (until a full stop is read) and outputs the number of letters, digits and commas that were in the line.  Use ctype functions.

my answer :true or false

#include <iostream>

using namespace std;

?

?

char type_of_char()

{

char x=' ';

cout<<"enter any character to dtermine it is type \n";

cin>>x;

return x;

}

int main()

{

char y=' ';

y=type_of_char();

if(y=='a'&& y<='z')

cout<<"the caracter you entered is small letter ";

else

if(y=='A'&& y<='Z')

cout<<"the number you entered is capital letter ";

else

if(y=='0'&&'9')

cout<<"the carcter you entered is digit ";

else

cout<<"the charcter you entered is spical charcter ";

if(y==';')

cout<<"the charcter you entered is commas ";

?

system("pause");

return 0;

}

?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.