0

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 by happygeek: fixed formatting

4
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by Schol-R-LEA
0

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??

0

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

0

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!!!!

0

hmmm ... Try placing

system("pause");

before

return 0;

hope it will solve the problem!!!!

thanks it worked

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.