Home TechnologyProgrammingC++ Subscribe to RSS

Can You Write A Program To Check Whether No Is Prime Or Not Prime In Turbo C++?

Answer Question

1 Answer - Sort by: Date | Rating

    //Checking wheather a number is prime.
    #include<iostream.h>
    #include<conio.h>
    void main(){
    int number=0;
    clrscr();
    cout<<"Enter a number to check:";
    cin>>number;
    bool prime=true;
    for(int i=2;i<number;i++){
    if(number%i==0){
    prime=false;
    break;
    }
    }
    if (prime)
    cout<<"nEntered number is prime.";
    else
    cout<<"nEntered Number is not Prime.";
    getch();
    }
    0 0

    Alon_nad  

    answered 4 months ago

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International