Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

Learn everything about programming

C++ program to find out the factors of given number

YASH PAL, 31 July 202422 August 2024

In this post, we will write a C++ program to find out the factors of a given number. the first user will enter the number and then the program will print the factors of a given number.

C++ program to find out the factors of given number

C++ program to find out the factors of a given number.

#include<iostream>
#include<conio.h>

int main()
{
   system("cls");

    int n,i,j,res;

    std::cout<<"Enter any number = ";
    std::cin>>n;

    for(i=1;i<=20;i++)
        for(j=2;j<=i;j++)
            if(n%j == 0)
            {
                std::cout<<j<<std::endl;
                n = n/j;
            }

    getch();
    return 0;
}


Output

Enter any number = 18
2
3
3
C++ Programming Tutorials coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes