Answer to Question #283285 in C++ for Adeel

Question #283285

write a program in C++ that takes a number from user and prints the first three multiples and first three factors of that number

1
Expert's answer
2021-12-28T12:59:51-0500
#include <iostream>
using namespace std;
int main() 
{   
 int n, i;   
 cout << "Enter a positive integer: ";   
 cin >> n;   
 cout << "Factors of " << n << " are: ";   
   for(i = 1; i <= n; i++) 
{     
   if(n % i == 0)         
   cout << i << " ";   
 }  
  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