A very simple program that I wrote using C++ that will ask the user to give a number and then our program will display the factors of the given number. The code is very short and easy to understand. I hope you will find my work useful. I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in writing this program. Thank you.
I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.
Sample Program Output
Program Listing
factors.cpp
#include <iostream>
using namespace std;
int main()
{
int value_number=0, a=0;
cout << "=================================================";
cout << "\n\n";
cout << "\t Factors of a Number in C++";
cout << "\n\n";
cout << "======= Created By Jake Pomperada, MAED-IT =======";
cout << "\n\n";
cout << "Give a number :";
cin >> value_number;
cout << "\n\n";
cout << "The factors of " << value_number << ".";
cout << "\n\n";
for(a=1; a <= value_number; a++)
{
if (value_number % a == 0)
{
cout << " " << a << " ";
}
}
cout << "\n\n";
cout << "End of Program";
cout << "\n\n";
}
No comments:
Post a Comment