Is it possible to put my c++ code into a window rather than opening in command prompt?


My code is: Is it possible to put this in a window instead of opening up a command prompt as I feel that would be more user-friendly? And would just look better overall I have Searched online and haven’t found any way to put any code in a window.

#include <iostream>

using namespace std;

int main()
    while (true) {
        string s;
        int n, i, m = 0, flag = 0;
        cout << "(press 'x' to exit) Enter the Number to check if It's a prime Number or not: ";
        cin >> s;

        if (s == "x")

        n = atoi(s.c_str());
        m = n / 2;

        for (i = 2; i <= m; i++)
            if (n % i == 0)
                cout << "That's not a prime number." << endl;
                flag = 1;
        if (flag == 0)
            cout << "That's a prime number." << endl;



You can follow the microsoft docs tutorial for creating a window.

You won’t be able to use std::cout and std::cin as these are console specific.

Answered By – Garfield1002

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published