Question

Hey guys. I am new to coding. And I need your help in answering this problem...

Hey guys. I am new to coding. And I need your help in answering this problem for me. You have to answer this problem using only C++ programming language. Thanks.

"Write a program that asks the user for an integer value, num. The program calculates the total number of factors of num. For example, if the user enters 12, the program should print out 6 (1,2,3,4,6,12)."

0 0
Add a comment Improve this question Transcribed image text
Answer #1

o/p:

code:

#include<iostream>

using namespace std;

int main() {
   int num, i, j = 0;
   int fact[100];
   int count = 0;

   cout << "Enter the value: ";
   cin >> num;

   cout << "The factors of " << num << " are : ";

   for(i=1; i <= num; i++) {
      if (num % i == 0) {
        fact[j] = i;  // stroring the factors in an array
        
        // incrementing the counters
        count++;
        j++;
      } 
   }


   // displaying the output
   cout << count << " (";
   for(i = 0; i < count; i++) {
     cout << fact[i];

     if(i != count - 1) {
       cout << ", ";
     }
   }
   cout << ")";

   return 0;
}

For help please comment.

Thank you

Add a comment
Know the answer?
Add Answer to:
Hey guys. I am new to coding. And I need your help in answering this problem...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hi guys, i need the coding, please help me. (Must using KEIL uversion software). TQ Write...

    Hi guys, i need the coding, please help me. (Must using KEIL uversion software). TQ Write a coding for Counter to count from 00 until 99 (in decimal). Display the result at 2 BCD 7- segment attached to address 0x20000000 and 0x20000001.

  • Hey guys, I am having a lot of trouble with my homework. Could you please help?...

    Hey guys, I am having a lot of trouble with my homework. Could you please help? I thumbs up anyone who gives a thorough explanation and shows the work! I really need to understand these concepts! Thanks! 1) At 25 °C, the Ka for formic acid (HCO2H) is 1.8 x 10-4. What is the pH of a 0.10 M aqueous solution of lithium formate (LiHCO2)? 2) What is the pH (aq., 25 °C) of this solution: adding 1.64 grams of...

  • Hey guys, I am having a lot of trouble with my homework. Could you please help?...

    Hey guys, I am having a lot of trouble with my homework. Could you please help? I thumbs up anyone who gives a thorough explanation and shows the work! I really need to understand these concepts! Thanks guys! 1) Z- is a weak base. An 0.350 M aqueous solution of NaZ is prepared. The pH of the solution was 8.93 at 25.0°C. The Kb of Z- is: 2) The base-ionization constant of ethylamine (C2H5NH2) is 6.4 x 10-4 at 25.0...

  • Hey guys I need help with homework. Certain amino acids are more energetically expensive than others...

    Hey guys I need help with homework. Certain amino acids are more energetically expensive than others (tryptophan versus glutamate). Thus, when proteins are moved to the cell surface, extended outside the surface, or secreted out of the cell, there is a potential harm. Why is this potentially harmful, and what adaptations do bacteria have for this potential loss? Give an example.

  • Hey guys, I am having a lot of trouble with my homework. Could you please help?...

    Hey guys, I am having a lot of trouble with my homework. Could you please help? I thumbs up anyone who gives a thorough explanation and shows the work! I really need to understand these concepts! Thanks a bunch! 1) At 25 °C, the pH of a 0.15 M aqueous solution of CsZ (the cesium salt of HZ) is 10.70. What is the Ka for HZ? 2) Calculate the pH of 0.586 M anilinium hydrochloride (C6H5NH3CI) solution in water at...

  • Hey guys, I am having a lot of trouble with my homework. Could you please help?...

    Hey guys, I am having a lot of trouble with my homework. Could you please help? I thumbs up anyone who gives a thorough explanation and shows the work! I really need to understand these concepts! Thanks in advance! 1) At 25 °C, the pH of a 0.15 M aqueous solution of CsZ (the cesium salt of HZ) is 10.70. What is the Ka for HZ? 2) Calculate the pH of 0.586 M anilinium hydrochloride (C6H5NH3CI) solution in water at...

  • I need help with this python programming exercise, please! thanks in advance Create a Python script...

    I need help with this python programming exercise, please! thanks in advance Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...

  • the coding language is just the basic c language and here is my first attempt at...

    the coding language is just the basic c language and here is my first attempt at this problem my problem is that if the user inputs a number that is equal to a number that has been entered previously the code will never end until the user enters a number that is bigger than any other number previously entered any help will be helpful Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program...

  • hey guys can i get some help with the above problem 2). Your business needs $200,000...

    hey guys can i get some help with the above problem 2). Your business needs $200,000 15 months from now. You need to buy a bond to finance the $200,000. The bond earns 5% annually with simple interest. How much should you purchase the bon at to finance the $200,000?

  • I really need help on this programming problem that am doing in Visual Studio 2019 in...

    I really need help on this programming problem that am doing in Visual Studio 2019 in C++ Submit your .cpp file as well as the input file, the output file, and the screen shot of all the files tiled next to each other here! Instructions: Write a menu driven program that has three options: Option 1: Write a function that calculates the tax for an iphone. The price and the tax rate should be asked from the user. Input validation:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT