Results 1 to 3 of 3

Thread: Program to write prime factor of given number:

  1. #1
    BrooksGray is offline Senior Member
    Join Date
    Dec 2009
    Posts
    231
    Rep Power
    3

    Default Program to write prime factor of given number:

    I have to write a agenda to print the primary factor of the given number. Can anybody help me to write the program to print prime factor of given number?

    Any help would be highly appreciated…

  2. #2
    CruzPowell is offline Senior Member
    Join Date
    Dec 2009
    Posts
    224
    Rep Power
    3

    Default

    1) try this
    main()
    {
    int a,c=0,i,n;
    printf("enter the number to be checked");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
    a=n%i;
    if(a=0)
    {
    c=c+1;
    }
    }
    if (c=2)
    { printf("the given number is prime"); }
    else
    printf("the given number is not prime");
    }

  3. #3
    FosterWood is offline Senior Member
    Join Date
    Dec 2009
    Posts
    215
    Rep Power
    3

    Default

    2) Try the given code below which is helpful for u.
    void main()
    {
    int i,n;
    printf("enter the number to be checked");
    scanf("%d",&n);
    for(i=2;i<=n;i++)
    {
    if(n%i==0)
    printf("The number is prime number")
    }
    else
    printf("the given number is not a prime number");
    getch();
    }

Similar Threads

  1. Write a C++ program that reads a floating point number
    By FosterWood in forum Programming
    Replies: 1
    Last Post: 06-15-2010, 02:36 PM
  2. Replies: 2
    Last Post: 05-14-2010, 01:30 PM
  3. Program for prime numbers in c
    By ScottWright in forum Programming
    Replies: 2
    Last Post: 04-30-2010, 01:54 PM
  4. Display Prime Number in C#
    By TorresScott in forum Programming
    Replies: 2
    Last Post: 03-18-2010, 11:50 AM
  5. C program to reverse a number
    By Millerjames in forum Programming
    Replies: 1
    Last Post: 01-13-2010, 05:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48