Odd-Prime number checker program in C++ || Conditional Statements || C++
In this we are going to see how to make a Program in C++ to check the number is Prime Number or not.

The code given below can be used for TURBO C++ Compiler:-

#include<iostream.h>
#include<conio.h>

void main()
{
        clrscr();
	int a, c = 0;
	cout<<"Enter number";
	cin >> a;
	if (a % 2 != 0)
	{
		if (a % 2 == 0)
		{
			c = 0;
		}
		if (c == 1)
		{
			cout<<"odd prime number";
		}
		else if (c == 0)
		{
			cout <<"Not an odd prime number";
		}
	}
	else
	cout<<"Not an odd prime number";
	getch();
}
    
    

The code given below can be used for g++/gcc Compiler:-

#include<iostream>
using namespace std;

int main()
{
	int a, c = 0;
	cout<<"Enter number";
	cin >> a;
	if (a % 2 != 0)
	{
		if (a % 2 == 0)
		{
			c = 0;
		}
		if (c == 1)
		{
			cout<<"odd prime number";
		}
		else if (c == 0)
		{
			cout <<"Not an odd prime number";
		}
	}
	else
	cout<<"Not an odd prime number";
	return 0;
}
    
    

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post