Tuesday 8 January 2019

c++ - converting char to int in while loop

I am developing a calculator program in c++. But the problem is when I try to convert the character into integer it shows runtime error. The code is given below.



#include
#include


void main()
{
clrscr();
int num,sum=0;
cout<<"Enter the number"< cin>>num;
while(num!='=')
{
sum=sum+num;

cin>>num;
}
cout<<"The sum is"< getch();
}


The program runs well i.e it takes the input correctly but when I used to press '=' sign then it shows nothing but only the black screen. Please help me. Thankyou.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...