What is the misatake in it????

#include<iostream.h>
#include<conio.h>
int main()
{
clrscr () ;
int value1, value2, sum ;
cout<<"enter value1: " ;
cin>>value1 ;
cout<<"enter value2: " ;
cin>>value2 ;
sum =value1+value2 ;
cout<<"the sum is: " <<sum ;
return 0 ;
}

i am using dev c++.
it only takes input ,no output was shown.

You are missing an end line, try this.

cout<<"the sum is: " <<sum <<endl;

The problem is not really that you need to print an end of line, but you need to flush the output, std::endl does this for you

2 Likes

You need to also type

getch();

Your ouput was not shown as it doesn’t clear the screen after you input is taken,try doing it

I just modified your code a bit . I added a getchar() and system(“PAUSE”). The system pauses to print output. Try using other compilers or IDE to avoid these troubles

#include
#include<stdlib.h>
using namespace std;
int main()
{

int value1, value2, sum ;
cout<<"enter value1: " ;
cin>>value1 ;
cout<<"enter value2: " ;
cin>>value2 ;
sum =value1+value2 ;
cout<<"the sum is: " <<sum<<endl<<endl ;
getchar();

system(“PAUSE”);
return 0 ;
}

before return 0 u add getch() or system(“pause”) if using dev c++ otherwise it will work…

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
int main()
{
int value1, value2, sum ;
cout<<"enter value1: " ;
cin>>value1 ;
cout<<"enter value2: " ;
cin>>value2 ;
sum =value1+value2 ;
cout<<"the sum is: " <<sum ;
getch();
return 0;
}

IT’S RUNNING IN DEV-C++…

DO NOT USE UPPERCASE !!!

1 Like

just use getch(); at the last before }.

//