Skip to content
engineeringhulk logo

EngineeringHulk

Engineering Content

  • Home
  • General
  • Manufacturing Engineering
  • Automobile Engineering
  • Universities and Colleges
  • Thermodynamics
  • Contact us
  • McMaster Carr
    McMaster Carr: A must know marketplace Manufacturing Engineering
  • NC Motion Control Systems
    Numerical Control (NC) Motion Control Systems Manufacturing Engineering
  • hydraulic braking system
    Hydraulic Brake System – Construction & Working Automobile Engineering
  • Study Novels
    Study Novels: A Deep Dive into the World of Fiction General
  • Assam capital
    Assam Capital – Comprehensive Guide in 2023 General
  • A level Mathematics tutor in Hong Kong (HK)
    How to find A level Mathematics tutor in Hong Kong (HK) General
  • What is plain cement concrete (PCC) in foundation construction?
    What is plain cement concrete (PCC) in foundation construction? General
  • Metal Machining
    The Evolution of Metal Machining in Automotive Manufacturing General
  • UPSC preparation
    UPSC Syllabus for 2024 – Detailed overview General
  • Mandela effect
    Mandela Effect – Examples, Impact, & Significance General
  • Types of solar panels
    Discover the Different Types of Solar Panels 2023 Solar Energy
  • Grinder Machine
    Grinder Machine – Working, Types, Applications, Pros & Cons Manufacturing Engineering
  • SEBI grade a result 2022
    SEBI Grade A Result 2022 – Direct PDF Download News
  • AARP Games
    AARP Games: A Guide to Fun & Brain-Stimulating Entertainment General
  • Amyloidosis disease
    Amyloidosis: Causes, Risk Factors, diagnosis & treatment 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

  • 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
  • Quan­tum Com­puter
    Quantum Computers: Revolutionizing the Future Computer Engineering
  • Micro programmed control unit
    Micro programmed control unit Computer Engineering
  • StAX API Maven
    StAX API Maven Computer Engineering
  • NetSuite CRM
    NetSuite CRM – Features, Benefits & Disadvantages Computer Engineering
  • Microprogramming
    Microprogramming Computer Engineering
  • Best courses after computer engineering
    Best courses after computer engineering Computer Engineering
  • Classification of computer
    Classification of computer Computer Engineering
  • encapsulation in c++
    encapsulation in c++ Computer Engineering
  • Domains of AI (Artificial Intelligence)
    Domains of AI (Artificial Intelligence) Computer Engineering
  • Google Compute Engine (GCE)
    Google Compute Engine Computer Engineering
  • who is the father of computer science
    Who is the father of computer science Computer Engineering
  • Operating System Functions
    Operating System (OS) Functions: Comprehensive Guide Computer Engineering
  • Dijkstra’s Algorithm
    Dijkstra’s Algorithm – A Detailed Information 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)
  • Engineering and Machinery (1)
  • General (328)
  • Health & Wellness (2)
  • Healthcare (1)
  • Manufacturing Engineering (91)
  • News (3)
  • Renewable sources of Energy (27)
    • Energy from Biomass (5)
    • Geothermal Energy (6)
    • Solar Energy (1)
    • Wind Energy (3)
  • Scholarships (22)
  • Thermodynamics (17)
  • Universities and Colleges (26)
  • 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 Detail of Biogas Generation Plant in 2024
  • BBA Aviation Course, Fees, Syllabus, Jobs & Scope
  • Top State Universities in Delhi: Ranking, Types, Fees
  • What is UGC (University Grants Commission) – Students Guide
  • Automobile Clutch: All the detailed information in 2024
  • Automobile Clutch Friction Materials – Students Guide
  • Sliding Mesh Gear Box – Construction and Working
  • Constant Mesh GearBox – Construction and Working
  • 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: Diagram, Construction & Working
  • 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
  • BSF Head Constable Ministerial Exam Syllabus

Recent Posts

  • The Evolution of Metal Machining in Automotive Manufacturing
  • IQ Test for 1st Standard Students – Fun 15 Question Quiz
  • Check Engine Light Flashing: Causes, Risks, and Immediate Actions
  • The Role of WAN in Modern Network Infrastructure
  • Duleep Trophy:India’s Prestigious Domestic Cricket Tournament
  • Why Bank of America is Cancelling Accounts? Urgent Warning to Customers
  • The Significance of “5” in Science, Religion, and Beyond
  • Boosting Brand Engagement with AI-Generated Visuals
  • Nvidia Groot N1: AI-Powered Humanoid Revolution
  • Blood Moon Total Lunar Eclipse Tonight: March 14, 2025
  • Scopely: Mobile Gaming with Innovation and Strategy
  • Employers Can Offer These Wellness Benefits To Retain Happy Employees
  • Navigating the Complexities of Group Health Insurance: Key Insights for Employers
  • Why You Should Never Use XXX Domains
  • How E-Commerce Businesses Can Reduce Shipping Costs
  • The Revolutionary Material: Graphene
  • FilmyZilla: Download Latest Movies & TV Shows | Features, Risks & Alternatives
  • Samsung Galaxy S25 Ultra-Launch Date 22 January 11.30pm 2025
  • How to Improve Your Shipping Strategy with Technology
  • Sustainability as Strategy: Green Business Tactics for Long-Term Success
  • The Complete Guide To Royal Honey: Benefits, Uses & Considerations
  • Amlodipine: Uses, Benefits, and Side Effects
  • Metronidazole: Uses, Benefits, Side Effects, and More
  • 200+ Thought of the Day in English and Hindi in 2024
  • McMaster Carr: A must know marketplace
  • Stihl Chainsaw Reviews: Which Model is Right for You?
  • Don’t go for the XNXP Personality Type Test 2022
  • Mind-blowing Futuristic 10 Technical Careers of 2025
  • Discovering Online Gambling with Nagad88
  • The Versatility of Industrial Pumps in Modern Applications
  • Jeetwin Bangladesh – A Comprehensive Review
  • Navigating the Nexus: How Computer Engineering Powers Online Gambling Platforms
  • Data Annotations Tech Legit or Scam? Detailed Honest Review
  • Apple Vision Pro is the New Social Media Sensation
  • Best of the Best False Ceiling Designs for the Bedroom
  • Katana: The Sword of the Samurai
  • Discover the Potential of GPT66X: Revolutionizing AI Across Industries
  • Teltlk: Amazing Instant Cross-Language Chat App
  • Tyres 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
  • Thermal Power Plant
    Site Selection for Thermal Power Plant – Explained in Detail Renewable sources of Energy
  • rbse
    RBSE (Rajasthan Board of Secondary Education) – A Comprehensive Guide General
  • An Introduction to Hypertext Markup Language (HTML): Benefits, Syntax, and Usage
    Hypertext Markup Language (HTML): Benefits, Syntax, and Usage Computer Engineering
  • MCB
    MCB full form General
  • Types of fasteners
    Types of Fasteners – Detailed Classification Manufacturing Engineering
  • N-Phenylethanamide
    N phenylethanamide General
  • Classification of surveying (2)
    Classification of surveying General
  • Minority scholarship
    Minority Scholarship-Eligibility, Amount, Types, Application Scholarships
  • Labour Card Scholarship
    Labour Card Scholarship: For Children of Unorganized Workers Scholarships
  • CNC
    What is Computer Numerical Control (CNC)? Manufacturing Engineering
  • State Universities in Delhi
    Top State Universities in Delhi: Ranking, Types, Fees General
  • Unit of hall coefficient
    Unit of Hall Coefficient – m³/A-sec & Ohm-cm/G General
  • The Enigma of Kohlrausch’s Law and its Contentious History
    Kohlrausch law General
  • Otto cycle and diesel cycle
    Otto cycle and diesel cycle Thermodynamics
  • first law of thermodynamics
    LIMITATIONS OF THE FIRST LAW OF THERMODYNAMICS Thermodynamics

Privacy Policy

Copyright © 2025 EngineeringHulk.

Powered by PressBook News WordPress theme