#include "stdafx.h"
#include "math.h"
#include <string>
#include <iostream>
using namespace std;
int main ()
{
    int x;
    cout << "Enter a number." << endl;
    cin >> x;
    int y = 1;
    int i = 0;
    while (i == 0 && y < sqrtf(x))
    {
        if (fmodf(x,y) == 0)
        {
            i = 1;
        }
        else
        {
            i = 0;
        }
        y++;
    if (i == 1)
    {
        cout << "Your number is prime." << endl;
    }
    else 
    {
        cout << "Your number is composite." << endl;
    }
    }
    return 0;
}
This is a code I created to test for primes. After sorting out several debugging issues I was able to run it.
It opened the command window, read 'Enter a number' and closed itself the second I entered a number.
Help?
 
     
    