C++
xxxxxxxxxx
using namespace std;
int checkPrimeNumber(int);
int main() {
int n1, n2;
bool flag;
cout << "Enter two positive integers: ";
cin >> n1 >> n2;
// swapping n1 and n2 if n1 is greater than n2
if (n1 > n2) {
n2 = n1 + n2;
n1 = n2 - n1;
n2 = n2 - n1;
}
cout << "Prime numbers between " << n1 << " and " << n2 << " are: ";
for(int i = n1+1; i < n2; ++i) {
// If i is a prime number, flag will be equal to 1
flag = checkPrimeNumber(i);
if(flag)
cout << i << " ";
}
return 0;
}
// user-defined function to check prime number
int checkPrimeNumber(int n) {
bool isPrime = true;
// 0 and 1 are not prime numbers
if (n == 0 || n == 1) {
isPrime = false;
}
else {
for(int j = 2; j <= n/2; ++j) {
if (n%j == 0) {
isPrime = false;
break;
}
}
}
return isPrime;
}
Enter two positive integers: 12 55 Prime numbers between 12 and 55 are: 13 17 19 23 29 31 37 41 43 47 53
Linux - anc-api-tools ని ఎలా ఇన్స్టాల్ చేయాలి
Linux - curvedns ని ఎలా ఇన్స్టాల్ చేయాలి
Linux - zenmap ని ఎలా ఇన్స్టాల్ చేయాలి
Python - సంఖ్య సానుకూలంగా ఉందా, ప్రతికూలంగా ఉందా లేదా 0 అని తనిఖీ చేయండి
C - పూర్ణాంకంలో అంకెల సంఖ్యను లెక్కించండి
C++ - సంఖ్య ప్రధానమైనదా కాదా అని తనిఖీ చేయండి
C - డైనమిక్ మెమరీ కేటాయింపును ఉపయోగించి అతిపెద్ద సంఖ్యను కనుగొనండి
C++ - లీప్ ఇయర్ని తనిఖీ చేయండి
Kotlin - ఒక సంఖ్యను రివర్స్ చేయండి
JavaScript - స్ట్రింగ్ కొన్ని అక్షరాలతో ప్రారంభమై ముగుస్తుందో లేదో తనిఖీ చేయండి
Linux - zstd ని ఎలా ఇన్స్టాల్ చేయాలి
C++ - కోషెంట్ మరియు రిమైండర్ను కనుగొనండి
Python - Excel (XLSX) ఫైల్లను వ్రాయడం
Linux - xbitmaps ని ఎలా ఇన్స్టాల్ చేయాలి
Java - ఒక సంఖ్యను రివర్స్ చేయండి
Kotlin - సంఖ్య యొక్క కారకాన్ని కనుగొనండి
Kotlin - ఒక సంఖ్యను n దశాంశ స్థానాలకు రౌండ్ చేయండి
Java - పిరమిడ్ మరియు నమూనాను సృష్టించండి
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month