0% found this document useful (0 votes)
33 views2 pages

Moin Ud Deen Mecahnical Engineer

The document contains a C++ program that takes the highest and lowest integers from the user and finds all the prime numbers between those two numbers. The program uses nested for loops, with an inner loop to check if each number from the first to the last is divisible by any number from 2 to itself, and only outputs the numbers with no remainders, which are the prime numbers between the ranges provided.

Uploaded by

Moin Ud deen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Moin Ud Deen Mecahnical Engineer

The document contains a C++ program that takes the highest and lowest integers from the user and finds all the prime numbers between those two numbers. The program uses nested for loops, with an inner loop to check if each number from the first to the last is divisible by any number from 2 to itself, and only outputs the numbers with no remainders, which are the prime numbers between the ranges provided.

Uploaded by

Moin Ud deen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MOIN UD DEEN

MECAHNICAL ENGINEER

QUESTION:
Write a program that take the highest and lowest
integers from user and find all the possible prime
numbers between them?
PROGRAM:
#include <iostream>
using namespace std;
int main ()
{
int first_num,last_num,i,j;
int count=0;
cout<<"Enter your first num"<<endl;
cin>>first_num;
cout<<"Enter your last num"<<endl;
cin>>last_num;
cout<<"Prime Numbers Between"<<first_num<<"and"<<last_num<<endl;
for(i=first_num;i<=last_num;i++)
{
count=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
count++;
}
}
if(count==0)
{
cout<<i<<endl;
}
}
system("pause");
return 0;
}
OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy