Sam_I_am
Sam_I_am

Reputation: 3

Compiling C++ in Visual Studio

I am new to c++. I am also new to Visual Studio. When I compile this code it says it succeeded, but it doesn't let me enter the number so that the function will run. I am not sure if I am writing the code wrong or just not understanding the compiling capabilities of Visual Studio. I'm use to java and NetBeans by the way.

    #include "pch.h"
#include <iostream>

int main()
{
    int no; // int named no.
    std::cout << "Enter any number: ";
    std::cin>>no;
    if (no % 2 == 0) {
        std::cout << "Even number,";
    }
    else
    {
        std::cout << "odd Number";
    }


}

Upvotes: 0

Views: 387

Answers (1)

Sabrina Tessier
Sabrina Tessier

Reputation: 79

I'm sorry I'm new to Stack Overflow so it won't let me write a comment but I think I know your problem. I think you might be compiling but not actually running your code. Try hitting Ctrl + F5 or go up to the 'Debug' tab and click 'Start without Debugging'.

Upvotes: 1

Related Questions