C++ Program for Prime Number

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

//Program for prime number
#include<iostream>
using namespace std;
int main()
{
      int n,i=2,f=0;
      system("cls");
      cout<<"Enter a number";
      cin>>n;
      while(i<n) 
      {
        if(n%i==0) 
       {
            f=1;
            break;
       }
       i++; 
      }
     if(f==0)
     cout<<"\n No is prime";
     else
     cout<<"\n No is not prime";
}

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *