Pleeeeeeeeeeeeeez fix it!!!
Hi guys, i m having a problem in the following source code. Please see if you can help.Thanks a lot.
#include<iostream>
#include<iomanip>
#include<cctype>
using namespace std;
int main()
{
char response='y';
int num,sum=0;
do{
cout<<"Enter a number: ";
cin>>num;
sum+=num;
cout<<"Do you want to enter another number?(y/n) ";
cin>>response;
response=tolower(response);
while((response!='y')||(response!='n'))
{
cout<<endl<<"Please enter y to continue or n to end. ";
cin>>response;
}
}while(tolower(response=='y'));
cout<<endl<<"The sum of numbers that you entered is "<<sum<<"."<<endl;
return 0;
}
When executed, the program enters an infinite loop (i m clueless about that!!).
This was compiled on VC++ 6.0. Make appropriate changes for your compiler.
Pleeeeeeeeeeeeeeeeeeeeeeez help!
|