Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

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

YASH PAL, 31 July 202427 January 2026

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 Programs

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

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