Saturday, August 18, 2012

Prime Factors

Assalamu Alaikum. Hope, you all are well by the grace of Almighty ALLAH. Today we learn how to find out the prime factors of an integer by C programming. Take a look at the problem.

Problem: A positive integer is entered through the keyboard. Write a program to obtain the prime factors of this number.

Sample Input:  24
Sample Output: 2, 2, 2, 3



Solution:
The Prime Factors of a positive integer are the prime numbers that divide the integer exactly, without leaving a remainder. For example Prime Factors of 24 are 2, 2, 2 and 3 whereas Prime Factors of 35 are 5 and 7.

Now take a look at the program.


We can also do this program by the following way. Take a look..


We can also do this program by the following way. Take a look..


We can also do this program by the following way. Take a look..


We can also do this program by the following way. Take a look.


We can also do this program by the following way. Take a look.


We can also do this program by using a flag. Take a look.




Thank You all..



0 comments:

Post a Comment