hey i just switched from turbo c++ to dev c++
i cant run the following program please help

#include<iostream>
using namespace std;
int main()
{
int n;
int k;
cout<<"Enter the values\n";
cin>>n;
cin>>k;
if (n>k)
{cout<<"The value entered first is greater ";}
else
 {cout<<"The value entered 2nd is greater";}
return 0;
}

What error are you getting?

I just run your code in Microsoft Visual Studio and I didn't face any problem. It compiled without any error and executed without any problem also doing exactly what I was expecting it to do i.e. comparison of numbers. So, it should run properly on DevC++ too.

Can you please explain a little more what kind of problem are you having in running this problem. is it a compilation error? or does the output screen don't stay long enough for you o see the final output?? or something else??
If it is a compilation error then what the exact error statement is??

I just run your code in Microsoft Visual Studio and I didn't face any problem. It compiled without any error and executed without any problem also doing exactly what I was expecting it to do i.e. comparison of numbers. So, it should run properly on DevC++ too.

Can you please explain a little more what kind of problem are you having in running this problem. is it a compilation error? or does the output screen don't stay long enough for you o see the final output?? or something else??
If it is a compilation error then what the exact error statement is??

i know there is no error in the program
it compiles correctly
but as soon as i enter the value for k and press enter the program widow closes

You need to find out how to keep the console window open. see here to begin with
P.S you have no contingency for the numbers being the same.

i know there is no error in the program
it compiles correctly
but as soon as i enter the value for k and press enter the program widow closes

hmmm ... try placing

system("pause");

before

return 0;

Hope it will solve the problem!!!!

hmmm ... Try placing

system("pause");

before

return 0;

hope it will solve the problem!!!!

thanks it worked

I should point out that Dev-C++ is itself a bit old, as it hasn't been maintained after 2005. Also, neither the Code::Blocks IDE or the Visual C++ Express IDE suffer from this particular problem - both pause the output automatically at the end of a console program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.