In this program, we are going to share a CPP program to remove punctuation from a given string. If you are a beginner and want to start learning the C++ programming, then keep your close attention in this tutorial as I am going to share a program for CPP program to remove punctuation from a given string.
Copy the below C++ program and execute it with the help of GCC compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#include <bits/stdc++.h> using namespace std; bool isPrime(int n) { // Corner cases if (n <= 1) return false; if (n <= 3) return true; // This is checked so that we can skip // middle five numbers in below loop if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) { if (n % i == 0 || n % (i + 2) == 0) { return false; } } return true; } // Utility function to check power of two bool isPowerOfTwo(int n) { return (n && !(n & (n - 1))); } int main() { int n = 43; if (isPrime(n) && (isPowerOfTwo(n * 3 - 1))) { cout << "YES\n"; } else { cout << "NO\n"; } return 0; } |
YES
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.