plz send me the code of this-prime number problem

Discussion in 'C' started by mahzabin, Jul 18, 2011.

  1. mahzabin

    mahzabin New Member

    Joined:
    Jul 18, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    plz somebody help me with this C code...i need it for my assignment..i tried to do it...but its not working.the assignment is that.."write a C program that will give the prime number between 1-10...(using loops n break)
     
  2. gpk kishore

    gpk kishore New Member

    Joined:
    Jun 30, 2011
    Messages:
    82
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int i,c=0,n;
    clrscr();
    printf("Enter any number");
    scanf("%d",&n);
    for(i=1,c=0;i<=n;i++)
    {
    if(n%i==0)
    c++;
    }
    if(c==2)
    printf("%d",i);
    else
    break;
    getch();
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice