Skip to content
EngineeringHulk

EngineeringHulk

Free Educational Notes

  • Home
  • Automobile
    • Module 1
      • Clutch
      • Propellar Shaft & Axle
      • Transmission
    • Module 2
      • Braking System
      • Final Drive and Differential
      • Steering System
    • Module 3
      • Suspension System
      • Wheels & Tyres
    • Module 4
      • Automotive Electrical System
    • Module 5
      • Body Engineering
    • Module 6
      • Recent trends in Automobiles
  • IT
  • general
  • Manufacturing
  • Renewable Energy
    • Energy from Biomass
    • Energy from the ocean
    • Geothermal Energy
    • Hydrogen Energy
    • Introduction to Energy Sources
    • Solar Energy
    • Wind Energy
  • Thermodynamics
  • Contact us
  • Toggle search form
  • Middle Georgia state university
    Middle Georgia state university – Fees, Admission, Location Universities and Colleges
  • Bioengineering's Role in Health
    Understanding Bioengineering’s Role in Health general
  • Emporia state university
    Emporia State University – Fees, Admission, Courses & more Universities and Colleges
  • engineering hulk
    Material Removal Techniques in Manufacturing Process Manufacturing Engineering
  • alpha brain
    Alpha Brain: Unleashing the Power of the Mind general
  • Laser cutting machine
    Laser cutting machine – Types, Working, Advantages Manufacturing Engineering
  • Top 10 Engineering Colleges in Hyderabad
    Top 10 Engineering Colleges in Hyderabad general
  • Maryland Lacrosse - Location, Fees, Admission & More
    Maryland Lacrosse – Location, Fees, Admission & More Universities and Colleges
  • Types of Valves
    Types of Valves – use with Advantages and Disadvantages Manufacturing Engineering
  • Jostle alternatives
    Jostle alternatives Computer Engineering
  • BBA Aviation Course
    BBA Aviation Course, Fees, Syllabus, Jobs & Scope general
  • PES Univesrity
    PES University Campus, Fees, Admission, Courses general
  • Google Gemini AI
    Google Gemini AI: The Most Advanced AI Algorithm? Computer Engineering
  • 180 c to f
    What is 180 Degrees Celsius In Fahrenheit (180 C to F)? general
  • fastest century in t20
    The Fastest Century in T20: Record That Continues to Impress general
prime number program in c++

Prime number program in c++

Posted on March 26, 2023April 13, 2023 By Admin

Here’s an example program in C++ that checks whether a given number is prime or not:

#include <iostream>

using namespace std;

bool isPrime(int n) {

    if (n <= 1) {

        return false;

    }

    for (int i = 2; i*i <= n; i++) {

        if (n % i == 0) {

            return false;

        }

    }

    return true;

}

int main() {

    int num;

    cout << “Enter a number: “;

    cin >> num;

    if (isPrime(num)) {

        cout << num << ” is a prime number.\n”;

    } else {

        cout << num << ” is not a prime number.\n”;

    }

    return 0;

}

In this program, the isPrime() function takes an integer n as its argument and returns true if it is a prime number, or false otherwise. The function uses a simple algorithm to check for primality: it tests whether n is divisible by any integer from 2 up to the square root of n. If n is divisible by any of these integers, then it is not a prime number.

In the main() function, the program prompts the user to enter a number, reads the input using cin, and then calls the isPrime() function to check whether the number is prime or not. The program then prints the result to the console using court.

Also, read An Introduction to Hypertext Markup Language (HTML): Benefits, Syntax, and Usage

Computer Engineering

Post navigation

Previous Post: Smallest odd prime number
Next Post: What is co prime number?

Related Posts

  • StAX API Maven
    StAX API Maven Computer Engineering
  • how to become a cyber security engineer
    How to become a cyber security engineer? Computer Engineering
  • Big Data
    Big Data – Meaning, Significance, Applications Computer Engineering
  • Computer shortcut keys
    Computer shortcut keys Computer Engineering
  • GPT66X
    Discover the Potential of GPT66X: Revolutionizing AI Across Industries Computer Engineering
  • Issues In the Design Of The Code Generator
    Issues In the Design Of The Code Generator Computer Engineering
  • Quan­tum Com­puter
    Quantum Computers: Revolutionizing the Future Computer Engineering
  • Micro programmed control unit
    Micro programmed control unit Computer Engineering
  • Types of CSS (Cascading Style Sheet)
    Types of CSS (Cascading Style Sheet) Computer Engineering
  • Best courses after computer engineering
    Best courses after computer engineering Computer Engineering
  • C operators
    C operators – All 7 types with detailed explanations Computer Engineering
  • A Brief Overview of Bentham and Hooker's Classification System
    Bentham and hooker classification Computer Engineering
  • Cassandra DB pros and cons
    Cassandra DB pros and cons Computer Engineering
  • Google Compute Engine (GCE)
    Google Compute Engine Computer Engineering
  • google bard ai
    Google bard AI Computer Engineering

Categories

  • Automobile Engineering (35)
    • Module 1 (13)
      • Clutch (3)
      • Propellar Shaft & Axle (2)
      • Transmission (8)
    • Module 2 (10)
      • Braking System (5)
      • Final Drive and Differential (2)
      • Steering System (3)
    • Module 3 (3)
      • Suspension System (1)
      • Wheels & Tyres (2)
    • Module 4 (6)
      • Automotive Electrical System (6)
    • Module 5 (1)
      • Body Engineering (1)
  • Computer Engineering (41)
  • Electrical Engineering (7)
  • general (300)
  • Manufacturing Engineering (90)
  • News (2)
  • Renewable sources of Energy (28)
    • Energy from Biomass (6)
    • Geothermal Energy (6)
    • Solar Energy (1)
    • Wind Energy (3)
  • Scholarships (22)
  • Thermodynamics (17)
  • Universities and Colleges (25)
  • Advantages and disadvantages of Biogas
  • Advantages, disadvantages & application of geothermal energy
  • Magma Geothermal Energy Source
  • Prospects of Geothermal Energy in India
  • Analysis of Aerodynamic forces acting on windmill blades
  • Basic components of wind energy Turbine
  • Design Considerations of HAWTs and VAWTs
  • GEO-PRESSURIZED HOT DRY ROCK – Energy from Rocks
  • SOURCE OF GEOTHERMAL ENERGY
  • Hydrothermal Energy Sources/Resources
  • Biogas generation plants
  • Biomass conversion technologies Noted
  • Biomass Energy – Defenition, Benefits & Working
  • Filling a Biogas Digester for Starting
  • Constructional Details of Biogas Generation Plant
  • BBA Aviation Course, Fees, Syllabus, Jobs & Scope
  • Top State Universities in Delhi: Ranking, Types, Fees
  • What is UGC (University Grants Commission)?
  • Automobile Clutch | Types | Working | Pros | Cons | Uses
  • Automobile Clutch Friction Materials
  • Sliding Mesh Gear Box
  • Constant Mesh Gear Box
  • Synchromesh Gear Box
  • Overdrive in Automobile – Detailed Guide
  • Hydrodynamic Torque Converter
  • Troubleshooting and Remedies of the Transmission system
  • Propeller shafts and universal joints
  • Types of axles in Automobile Engineering
  • Types of Final Drive in Automobiles
  • Rear Differential – Construction, Working, Types & Features
  • Mechanical Brakes – Types, working, advantages & disadvantages
  • Hydraulic Brake System – Construction & Working
  • Brake Master Cylinder – Detailed Working Principle
  • Introduction to Antilock Braking System (ABS)
  • Requirements of Brake System in Automobiles
  • Steering Geometry in Automobile Engineering
  • What is Oversteer and Understeer in Automobile Engineering
  • Cornering power in Automobile
  • Suspension System in Automobile Engineering
  • Wheels and Tyres in Automobile Engineering
  • Starting system in Automobile Engineering
  • Bendix Drive in Automobile Engineering
  • Dynamo – Definition, Construction, & Working
  • Alternator in Automobile Engineering
  • Lead Acid Battery – Construction, Working, Advantages
  • Battery Charging – Methods, Advantages, & Disadvantages
  • Material Removal Techniques in Manufacturing Process
  • What is Computer Numerical Control (CNC)?
  • What is Direct Numerical Control (DNC)?
  • Numerical Control (NC) Procedure
  • Numerical Control (NC) Motion Control Systems
  • Mechanical properties of Metals
  • Heat-treatment of steel
  • what is Annealing? How it Works
  • What is the hot working and cold working of steel?
  • What are the Materials and Alloys used in Workshop?
  • MAT Entrance Exam 2022 – Everything you need
  • PES University Campus, Fees, Admission, Courses
  • SEBI Grade A Result 2022 – Direct PDF Download
  • Components of the internal combustion engine (IC Engine)
  • LIMITATIONS OF THE FIRST LAW OF THERMODYNAMICS
  • Law of Conservation of Energy: Statement with Explanation
  • Ultrasonic Machining
  • The vapor compression refrigeration cycle
  • A Refrigeration cycle operates between a condenser temperature of + 27
  • Discover the Different Types of Solar Panels 2023
  • Best courses after computer engineering
  • Gram seed – Rate, Production, Types, Harvesting
  • Types of ovules – Location, Components, Types, fun facts
  • Development of Dicot Embryo
  • Boiler Classification: Types, Components & Applications
  • Application of Zener diode – Advantages, Disadvantages
  • Role of Individuals in the Conservation of natural resources
  • Relationship between linear velocity and angular velocity
  • S.I unit of conductivity
  • Issues In the Design Of The Code Generator
  • Domains of AI (Artificial Intelligence)
  • Cymose Inflorescence
  • Top 10 Engineering Colleges in Hyderabad
  • Charlotte Engineering Early College
  • ISBM College of Engineering Pune
  • Tetravalency: Exploring the Unique Properties of Carbon
  • Dijkstra’s Algorithm – A Detailed Information
  • Microprogramming
  • Floyd Algorithm: Detailed Article 2023
  • Operating System (OS) Functions: Comprehensive Guide
  • Classifications Of DBMS (Database Management System)
  • Types of CSS (Cascading Style Sheet)
  • Diploma in Civil Engineering?
  • What is plain cement concrete (PCC) in foundation construction?
  • Toughest Exam In India
  • Basic School Teaching Course- BSTC
  • pstet – Punjab State Teacher Eligibility Test
  • National Institute of Technology- NIT
  • Intrusion Prevention Systems (IPS) – Detailed Overview

Recent Posts

  • Katana: The Sword of the Samurai
  • Discover the Potential of GPT66X: Revolutionizing AI Across Industries
  • Teltlk: Amazing Instant Cross-Language Chat App
  • Tires Unveiled: A Comprehensive Guide to Enhancing Vehicle Performance
  • Toyota’s Ammonia Engine: A Sustainable Innovation
  • Understanding Bioengineering’s Role in Health
  • Amazon GPT55X: A Transformative Content Generation Tool
  • How to Flip a coin to win frequently
  • Google Cloud Next Agenda 2023-2024
  • Halal Shawarma: A Culinary Delight Rooted in Tradition
  • Extraordinary Mushroom Species Discovered: “Ape Mushroom”
  • Bedford Recycling: Pioneering a Greener Tomorrow
  • The God Particle: Unraveling the Secrets of the Universe
  • Kinkyness Test: Unraveling the Mysteries of Your Desires
  • His and Her Marriage Novel: Intimate Narrative of Two Souls
  • Study Novels: A Deep Dive into the World of Fiction
  • Sculptura: A Deep Dive into the World of Artistic Expression
  • Rohu Fish: A Comprehensive Guide
  • Simple Strike Sequence: An In-Depth Guide
  • Partially Oriented Yarn (POY) – Detailed Overview
  • Understanding “Expell”: Definition, Usage, and Context
  • Saffron: Uses, Harvesting, Medical Properties and More
  • Blossom Word Game: Features, Tips, Strategy & More
  • Mastering the Art of CCIE Lab Passing: Proven Strategies
  • General Engineering Tolerances: Types, Methods & More
  • Electrical Discharge Machining (EDM): Types, Working & More
  • Non-Destructive Testing (NDT): An In-depth Exploration
  • Cold Welding: An Insight into Solid-State Joining
  • ISO Standards: Certification, Attributes and Challenges
  • Rapid Prototyping: Types, Methods, Steps and More
  • Knurling: Types, Process, Applications & More
  • Sheet Metal Fabrication: A Comprehensive Guide
  • CNC Mills: Working, Programming, Application & More
  • Flux Core Welding: Techniques, Benefits, and Applications
  • Fiber Laser: Illuminating Precision in Modern Manufacturing
  • Types of Metal: Detailed Classification
  • Welding Aluminium: Techniques, Challenges, and Applications
  • PipeBender/Tube Bender Machine Working & Applications
  • Product Life Cycle: Stages, Strategies, and Importance
  • Top 15 Exciting Startup Ideas for Business Students
  • What Channel Is CW on Optimum? – Updated Guide 2023
  • Lean Manufacturing: Production for Efficiency & Quality
  • Stick Welding: Equipment, Working, Techniques, and More
  • Metal Hemming: Techniques, Applications, and Benefits
  • Brazing: Process, Filler, Advantages, Applications & More
  • Soldering: Types, Machine, Process, Applications & More
  • TIG Welding: Equipment, Techniques, Applications & More
  • Metal Inert Gas (MIG) Welding: A Comprehensive Guide
  • Aircraft Spruce: Your One-Stop Shop for Aviation Needs
  • Direct Energy: Understanding its Concepts and Applications
  • Volcanic Ash: Formation, Impact, and Significance
  • 3D Reverse Engineering: A Deep Dive
  • Refrigerant Leak Detector: An Essential Tool in HVAC
  • Top 5 Mistakes after Knee Replacement with its Consequences
  • The Hip Thrust Machine: Benefits, Mechanics, and Usage
  • 10 Warning Signs of Mold Toxicity to Your Body & Health
  • Kora Online: Detailed Comprehensive Guide
  • Biscuiti Englezesti: English Biscuits for Better Digestion
  • How to find A level Mathematics tutor in Hong Kong (HK)
  • How Do I Get My CompTIA Security+ Certification
  • Diary of a Wimpy Kid Book: Series, Movies, Characters
  • Math Playground Top Fun Games: New Features
  • LK-99: Room Temperature Superconductor Discovery
  • Stiletto Nails: A Fashion Trend 2.0
  • Fire Kirin: A Thrilling Gaming Experience
  • Bubble Slides: A Slippery Adventure Worth Exploring
  • Kuromi: A Rebel Character with a Devilish Charm
  • Soap2Day: Watch or Stream the Latest Movies for free
  • Degloved Face Makeup Tutorial: A Gory Halloween Look
  • Ultrasonic Machining Process – Detailed Overview
  • Abrasive jet machining – Detailed Information 2023
  • Site Selection for Hydroelectric Power Plants
  • Site Selection for Nuclear Power Plant – In depth explained
  • Site Selection for Thermal Power Plant – Explained in Detail
  • Site Selection for Hydro Power Plant – Explained in Detailed
  • Buy Tesla Stock on eToro: A Comprehensive Guide
  •  Langmuir Systems: An Insight into Surface Chemistry
  • Pictory AI: Direct Script to the Video Creator
  • Dell EMC Partners: Powering Innovation and Transformation
  • Alpha Brain: Unleashing the Power of the Mind
  • Learn the ASL Alphabet: A Comprehensive Guide
  • Degloved Face: Causes, Treatment, and Prevention
  • Deep Neural Networks: A Complete Comprehensive Guide 2023
  • Internet of Things: Connecting the World Through Smart Technology
  • The Ultimate Guide to Glass Pinchies: Smoking Accessories
  • Laekerrt Espresso Machine: Elevate Your Coffee Experience
  • Quantum Computers: Revolutionizing the Future
  • Unleashing the Potential of Stroboscopes: An In-Depth Guide
  • Semiconductor Quantum Dots: The Power of Nanotechnology
  • Nanophotonics: Exploring the World of Light at the Nanoscale
  • Oskar Sala: The Pioneer of Electronic Music
  • Gama Pehlwan: The Wrestler Who Defined Strength & Discipline
  • ” . ” Full Stop Punctuation – Usage and Significance
  • Google Gemini AI: The Most Advanced AI Algorithm?
  • Otto cycle and diesel cycle
  • The Casting Process: A Comprehensive 2023 Guide
  • Car Chassis Frame: Definition, Types, & Materials Explained
  • Types of Fits in Engineering – 2023 Guide
  • Types of Pumps – A Comprehensive detailed article
  • Benson Boilers: Definition, Parts, Advantages, Disadvantages
  • Parts of Car Transmission
  • Understanding Lamont Boilers: A Comprehensive Guide
  • Electrochemical Grinding: Definition, Construction, Working
  • Orifice Meters: Definition, Construction, and Working
  • The Cochran Boiler: Components, Working, & Applications
  • Chemical Machining Process: Precise Material Removal
  • Cornish Boiler – Parts, working, Advantages, Applications
  • What is the construction and working of the Loeffler boiler?
  • Gate Valve: A Guide to its Working, Applications, and Types
  • Locomotive Boiler – Parts, working, and Applications
  • Magneto Ignition System: Function, Components, & Advantages
  • Babcock and Wilcox boiler – Defenition, Working, Application
  • Shaper Machines: A Comprehensive Guide
  • How to Multiply Fractions – A Step-by-Step Guide
  • How Many Seconds Are There in a Day, Month, and Year
  • What is 180 Degrees Celsius In Fahrenheit (180 C to F)?
  • How to Find the Midpoint in Mathematics
  • Supplementary Angles in Mathematics: Definition & Properties
  • Interpersonal Management: A Key to Successful Team Collab
  • Confidence Level Calculator: A Powerful Statistical Tool
  • What is a heterotroph
    What is a heterotroph? World of Organism Nutrition general
  • BBA Aviation Course
    BBA Aviation Course, Fees, Syllabus, Jobs & Scope general
  • Confidence Level Calculator
    Confidence Level Calculator: A Powerful Statistical Tool general
  • Air resistance
    Air resistance – Definition, Formula, Components, Factors general
  • Who discovered proton
    Who discovered proton general
  • Greater than sign with examples
    Greater than sign (>) with examples general
  • .
    ” . ” Full Stop Punctuation – Usage and Significance general
  • Accuracy vs Precision
    Difference between Accuracy vs Precision general
  • Data Bricks
    DataBricks: The Ultimate Solution for Big Data Processing Computer Engineering
  • Boiler classification
    Boiler Classification: Types, Components & Applications Thermodynamics
  • gk questions
    gk questions general
  • SIM full form
    SIM full form – Subscriber Identity Module general
  • Rabi crops
    Rabi crop general
  • Maryland Lacrosse - Location, Fees, Admission & More
    Maryland Lacrosse – Location, Fees, Admission & More Universities and Colleges
  • Automobile differential
    Rear Differential – Construction, Working, Types & Features Automobile Engineering

Privacy Policy

Cookie Policy

About us

Contact us

Careers

Copyright © 2023 EngineeringHulk.

Powered by PressBook News WordPress theme