Pages

APLIMAT - C++

So we decided to start the class all over again and made our final decision of making C++ our final Programming Language to tackle



 Source Code:

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

using namespace std;

int isPrime(int n)
{
for (int c = 2; c < n; c++)
{
if (n % c == 0) return 0;
}

return 1;
}
void main()
{
int x;

cout << "Enter number: ";
cin >> x;

if (isPrime(x))
{
cout << x << " is prime.";
}

else
{
cout << x << " is NOT prime.";
}

getch();
}

Alson Entuna

Hi I'm John Alson H. Entuna. I'm a student at De La Salle - College of Saint Benilde taking up BSIT- with Specialization in Game Design and Development.

No comments:

Post a Comment