Click here to Skip to main content
15,890,947 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: RegisterDeviceNotification in dbt.h undeclared identifier?? Pin
«_Superman_»24-Jul-13 18:40
professional«_Superman_»24-Jul-13 18:40 
AnswerRe: RegisterDeviceNotification in dbt.h undeclared identifier?? Pin
Richard MacCutchan24-Jul-13 21:24
mveRichard MacCutchan24-Jul-13 21:24 
GeneralRe: RegisterDeviceNotification in dbt.h undeclared identifier?? Pin
Vaclav_25-Jul-13 7:17
Vaclav_25-Jul-13 7:17 
GeneralRe: RegisterDeviceNotification in dbt.h undeclared identifier?? Pin
Jochen Arndt25-Jul-13 7:43
professionalJochen Arndt25-Jul-13 7:43 
GeneralRe: RegisterDeviceNotification in dbt.h undeclared identifier?? SOLVED Pin
Vaclav_26-Jul-13 5:50
Vaclav_26-Jul-13 5:50 
AnswerRe: RegisterDeviceNotification in dbt.h undeclared identifier?? SOLVED Pin
Richard Andrew x6426-Jul-13 12:26
professionalRichard Andrew x6426-Jul-13 12:26 
GeneralRe: RegisterDeviceNotification in dbt.h undeclared identifier?? Pin
Richard MacCutchan25-Jul-13 9:14
mveRichard MacCutchan25-Jul-13 9:14 
QuestionProblem with loop in C++ Pin
Kripa Khanal24-Jul-13 5:40
Kripa Khanal24-Jul-13 5:40 
I have a question regarding the following program. This program uses random variables and asks the user to enter the correct sum for 5 times. Until, we enter an integer the program runs well but as soon as we enter any double value or a character, the program gives incorrect message for the whole loop and comes out of the loop automatically. Why does this happen? Can anyone help me?
C++
#include<iostream> 
#include<ctime> 
using namespace std; 
int main() 
{ 
int num1=0; 
int num2=0; 
int correctanswer=0; 
int useranswer=0; 
srand(static_cast<int>(time(0))); 
for (int x=1; x<6; x++) 
{ 
num1=1+rand()%(100-1+1); 
num2=1+rand()%(10-1+1); 
correctanswer= num1+num2; 
cout<<"What is the sum of "<<num1<<" and "<<num2<<"?"; cin>>useranswer;
 if (useranswer==correctanswer) 
cout<<"Excellent! Correct Answer"; 
     else 
cout<<"Sorry!the correct answer is: "<<correctanswer; cout<<endl<<endl; 
} 
system("pause"); 
return 0; 
}

AnswerRe: Problem with loop in C++ Pin
pasztorpisti24-Jul-13 7:21
pasztorpisti24-Jul-13 7:21 
GeneralRe: Problem with loop in C++ Pin
Kripa Khanal25-Jul-13 12:06
Kripa Khanal25-Jul-13 12:06 
GeneralRe: Problem with loop in C++ Pin
pasztorpisti25-Jul-13 22:59
pasztorpisti25-Jul-13 22:59 
AnswerRe: Problem with loop in C++ Pin
Member 1014853124-Jul-13 16:13
Member 1014853124-Jul-13 16:13 
QuestionSerial Port Functor Pin
Jonathan Davies24-Jul-13 1:51
Jonathan Davies24-Jul-13 1:51 
AnswerRe: Serial Port Functor Pin
pasztorpisti24-Jul-13 3:29
pasztorpisti24-Jul-13 3:29 
AnswerRe: Serial Port Functor Pin
Chris Losinger24-Jul-13 10:26
professionalChris Losinger24-Jul-13 10:26 
GeneralRe: Serial Port Functor Pin
Jonathan Davies24-Jul-13 10:36
Jonathan Davies24-Jul-13 10:36 
QuestionGetModuleFileName and case sensitivity Pin
vikramlinux23-Jul-13 23:19
vikramlinux23-Jul-13 23:19 
AnswerRe: GetModuleFileName and case sensitivity Pin
«_Superman_»23-Jul-13 23:27
professional«_Superman_»23-Jul-13 23:27 
GeneralRe: GetModuleFileName and case sensitivity Pin
vikramlinux23-Jul-13 23:32
vikramlinux23-Jul-13 23:32 
GeneralRe: GetModuleFileName and case sensitivity Pin
vikramlinux23-Jul-13 23:36
vikramlinux23-Jul-13 23:36 
GeneralRe: GetModuleFileName and case sensitivity Pin
Richard MacCutchan24-Jul-13 0:25
mveRichard MacCutchan24-Jul-13 0:25 
AnswerRe: GetModuleFileName and case sensitivity Pin
SajeeshCheviry24-Jul-13 0:24
SajeeshCheviry24-Jul-13 0:24 
GeneralRe: GetModuleFileName and case sensitivity Pin
vikramlinux24-Jul-13 1:23
vikramlinux24-Jul-13 1:23 
SuggestionRe: GetModuleFileName and case sensitivity Pin
Richard MacCutchan24-Jul-13 4:56
mveRichard MacCutchan24-Jul-13 4:56 
GeneralRe: GetModuleFileName and case sensitivity Pin
vikramlinux24-Jul-13 16:56
vikramlinux24-Jul-13 16:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.