Answer to Question #341791 in C++ for Lulo

Question #341791

Write a program that reads in two integers and determines and prints if the first is a




multiple of the second.




a) first the program using if statements




b) then the program using if/else statements

1
Expert's answer
2022-05-16T16:07:46-0400





//***************** first.cpp *********************************
//first programm
#include <iostream>
using namespace std;
int main() {
  
  int a;//first number
  int b;//secon number
  cout<<"Please input first number: ";
  cin>>a;
  cout<<"Please input the second number: ";
  cin>>b;
  if(a%b==0)
    cout<<a<<"   "<<b<<endl;
  return 0;
}
//***********************************************************

//************************** second.cpp **********************
//second programm if/else
#include <iostream>
using namespace std;
int main() {
  
  int a;//first number
  int b;//secon number
  cout<<"Please input first number: ";
  cin>>a;
  cout<<"Please input the second number: ";
  cin>>b;
  if(a%b==0)
    cout<<a<<"   "<<b<<endl;
  else
    cout<<"Sorry the first isn't multiple of the second\n";
  return 0;
}
//**********************************************************

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS