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;
}

Edited 3 Years Ago by happygeek: fixed formatting

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

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

This article has been dead for over six months. Start a new discussion instead.